Client Script on Submit or Business Rule for after condition, which runs first?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 01:38 AM
Hi,
Client Script on Submit or Business Rule for after condition, which runs first?
I want to run the client script first?? Is it possible??
Thanks and Regards,
Chandra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 01:42 AM
Hi Chandra,
Client script will execute first and then after BR will execute.
Execution Order of Scripts and Engines - ServiceNow Wiki
Client Script Best Practices - ServiceNow Wiki
Business Rules Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2023 10:46 AM
Does this also apply to onSubmit Client scripts and g_scratchpad (which uses a display business rule?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 01:42 AM
Hi Chandra, definitively the Client Script on submit
The client scripts are running on your browser while the business rules are running on the servers.
Meaning, when the client script is executed, it doesn't even know (or care) if a business rule onBefore or onAfter will be executed later
For the server side, this Execution order of scripts and engines is useful.
When it make sense (meaning when someone is actually clicking on the records), the client side scripts would be executed after the "queries and the display business rules" but before the any step on this list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 01:43 AM
You may find below link useful.
http://wiki.servicenow.com/index.php?title=Execution_Order_of_Scripts_and_Engines#gsc.tab=0
Client-based code that executes in the browser, using Ajax or running as Javascript, always executes before the form submission to the server
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa