Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

order

22M61A05D8
Tera Contributor

Hi everyone,

I’m currently trying to get a clear and comprehensive understanding of execution order in ServiceNow — especially how Client Scripts, UI Policies, UI Actions, and Business Rules interact during different stages of form interaction and submission.

To get community insights, I’ve listed a few related questions below. I’d really appreciate detailed explanations or references to official documentation wherever possible.


🔹 General Execution Order Questions

  1. What is the complete client-side execution order for form load events in ServiceNow, specifically for Client Scripts and UI Policies?

  2. Can someone clarify the precise sequence in which onChange Client Scripts and UI Policies are evaluated when a field’s value changes on a form?

  3. I’m trying to understand the full lifecycle of a form submission. What is the execution order from onSubmit Client Scripts through to before and after Business Rules, and where do UI Actions fit into that?

  4. Where do UI Actions (both client-side and server-side scripts) fit into the overall execution order on a form, in relation to Client Scripts and UI Policies?

  5. What happens first on a form: a Client Script, a UI Policy, or the client-side script of a UI Action? Could you explain the conditions under which each would run?


🔹 Scenario-Based Questions

  1. I have an onLoad Client Script that sets a field value, and a UI Policy that hides that field if its value is “XYZ”. Which will execute first, and will the field be hidden correctly?

  2. I’m using an onSubmit Client Script for validation. If that script returns false, will any before Business Rules still run? What about other onSubmit Client Scripts?

  3. If I have a UI Action that has a client-side script to confirm an action, and then calls a server-side script, does that server-side script trigger before and after Business Rules like a standard form submission would?

  4. In a list view with onCellEdit Client Scripts, what is the exact order of operations when a cell is edited and saved, leading up to any before Business Rules

1 REPLY 1

NavinAgarwal
Mega Guru

Hi @22M61A05D8 ,

 

Here is the execution flow:

 

onLoad Client Scripts run first when a form is loaded.

UI Policies are applied after the onLoad Client Scripts.

For onChange events, both Client Scripts and UI Policies execute, but Client Scripts are triggered first.

onSubmit Client Scripts execute last, just before the form is submitted to the server.

 

Conflict Resolution:

If there is conflicting logic between a Client Script and a UI Policy, the UI Policy logic takes precedence. This ensures that the UI Policy's behavior is enforced on the form.

 

There are lot of articles/discussions in the community already to understand the execution order, I have shared few links below, please review and they should help you understand the sequence order better..

 

⚔️ Understanding Execution Order: Client Script vs... - ServiceNow Community

On-Change Client Side Scripting Scenarios - ServiceNow Community

Order of execution of business rules, ui policy, u... - ServiceNow Community

Order of Script Execution - Form submission - ServiceNow Community

Which one is exection order first Business rule... - ServiceNow Community

 

If you found my response helpful, could you please mark it as ‘Accept as Solution’ and ‘Helpful’? This small action goes a long way in helping other community members find the right answers more easily and supports the community.

 

Regards,
Navin