Calling User Event Script from another User Event

Calling User Event Script from another User Event

User event scripts are executed on the NetSuite server. They are executed when users perform certain actions on records, such as create, load, update, copy, delete, or submit. Most standard NetSuite records and custom record types support user event scripts.

The Most important thing is User event scripts cannot be executed by other user event scripts or by workflows with a Context of User Event Script. In other words, you cannot chain user event scripts.
You can execute a user event script from a call within a scheduled script, a portlet script, or a Suitelet. As a NetSuite Solution provider we will help you to show how User event can be called from another User event Script using Suitelet.
As we all know we cannot chain User event. Work around provided as NetSuite Customization to this is to create a Suitelet that has the same logic as that of first User Event Script. Consider the use case given below: Create or edit an Inbound Shipment record and upon saving, the After Submit function of the User Event script deployed to it will also update the Purchase Order associated with the Record and save.
The Purchase Order has another User Event Script deployed to it and is also triggered on After Submit.

The User Event script on Purchase Order updates fields. However the User Event script deployed on
the Purchase Order is not triggered since submitting the Inbound Shipment record is from another
User Event script. N/redirect Module to redirect to Suitelet on the After Submit function of User Event, passing the parameters needed like the Record Type and Record Id.

The sample code provided by NetSuite Solution provider below describes information from the Inbound Shipment User Event Script that passes the parameter Record Id to the Suitelet.

The page will redirect to Suitelet on After Submit function and pass the parameters to it

C:UsersSuryaDesktopsup1.PNG

Now it’s time to create Suitelet which will update the Purchase Order, The updated record will be able to trigger User event deployed to it. Refer the below screenshot for the Suitelet.

C:UsersSuryaDesktopsup2.PNG

In this way we can use schedule script and portlet also for the other use cases where business requirement is rotating around the concept of triggering user event from another user event script. Reference: NetSuite, SuiteScript 2.0 API guide, Netsuite Suiteanswer Feel free to reach out NetSuite Solution Provider for proper NetSuite implementation,
consultation and netsuite related technical stuff. Please comment your views on how suitescript 2.0 is better than 1.0.  For Netsuite Training (Including training for interviews), Support , Customization , Integration and Implementation contact us at:
Email : [email protected]

Facebook page : https://www.facebook.com/Netsuite-Academy-1591053827660082/

Linkedin : https://www.linkedin.com/in/sk-k-610836166/


Log out of this account

Leave a Reply