Hello Gurus,
I need help understanding why the User Event script is not triggering when M/R script updates the Invoice, here is my scenario:
- User Event script deployed on the Invoice record which set line fields
- M/R script called from the Suitelet with parameters that change the value of the body field.
Result:
M/R script edits the Invoice, but the User event is not triggered.
Expected Result:
User Event script to be triggered when the M/R script edits the invoice.
How the User Event script is deployed:
The user event script is deployed on the Invoice record and has one custom role set in the Audience tab - "Consolidated Invoices" ID: 1324. The Administrator role is not included in the audience.
User event is triggered when the Invoice is edited on the UI from the user with this role, but not from the M/R script.
Here is the screenshot of the User event script deployment on the Invoice record:
How the M/R is executed:
The M/R script is triggered from the Suitelet. The Suitelet's option "Execute as role" is set to that custom role, the same which is set on the User Event script deployment - "Consolidated Invoices" ID: 1324.
When the M/R is triggered:
When the M/R is triggered, the Invoice record gets loaded and saved by the M/R but the User event is not triggered.
As you can see in the script execution log, the Internal ID of the role is 1324 - "Consolidated Invoices" so I believe the User Event must trigger because its audience is set to this role.
Here is the code that I use to check the current user role:
var userObj = runtime.getCurrentUser();
log.debug('Internal ID of current user role: ' + userObj.role);
log.debug('Name of current user: ' + userObj.name);
log.debug('Internal ID of current user: ' + userObj.id);
Can you please explain why the User event is not triggering?
Thanks in advance!