Ajith Kumaran
05/19/2025, 3:21 PMCeligo AI
05/19/2025, 3:22 PMAI generated answer (using internal Slack threads):In NetSuite, the order of execution of User Event scripts (including
afterSubmit
scripts) is determined by the order in which they are deployed. However, there is no guarantee that one afterSubmit
script will completely finish before the next one starts.
If you have two User Event scripts and both have an afterSubmit()
function, they do not necessarily follow the order declared in the scripted record page. If one script fails because it uses a field that gets set by another one, you might need to refactor your scripts to ensure that all necessary fields are set before they are used.
One way to ensure that a field is set before it is used is to load and save the current record in the afterSubmit
script. However, be aware that this can have performance implications, especially if you are making changes to the record in the afterSubmit
.
If you want the code in an afterSubmit
to only run after a Map/Reduce task finishes, you might need to rethink your approach. The afterSubmit
function of a record will always run immediately after the record is saved to the database. It will not be tied to the completion of the Map/Reduce job.
You could consider using the N/runtime.Script
to detect a specific Map/Reduce, or check a box on the record and then run the afterSubmit
only if that box is checked. However, you can't tie it specifically to the end of the Map/Reduce.
If the logic needs to be tied to the end of a specific Map/Reduce, then it might be better to include that logic in the Map/Reduce script itself, rather than in a User Event. For example, you could move the logic from the afterSubmit
to the summarize phase of the Map/Reduce. However, be aware that Map/Reduce scripts are typically used for bulk processing and you don't want to do any bulk processing in the summarize or getInputData.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
05/19/2025, 3:22 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826667905
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823215783
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821884394
Celigo AI
05/19/2025, 3:22 PM