Closed lohart13 closed 3 hours ago
Sure, also please clarify how to reproduce the issue
Sure, in the below example the request object will be undefined if the user event script is trigged server side (such as via Suitelet or CSV import creating/editing a record) hence the need to check that request object is defined.
This currently needs the below eslint disable rule as the linter can see that the beforeLoadContext
interface shows request is always defined.
export const beforeLoad: EntryPoints.UserEvent.beforeLoad = ({ form, request }) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (request?.parameters) {
if ('success' in request.parameters) {
form.addPageInitMessage({
type: message.Type.CONFIRMATION,
title: 'Success',
duration: 5000,
});
}
}
}
Looking at the beforeLoad docs, the
request
parameter in the context can be undefined if the event was triggered by the server.I can submit a PR to fix this if you would like.