execution order

sanketkhot7
Tera Contributor

Execution Order of client side and server side scripting

6 REPLIES 6

Rafael Batistot
Mega Patron

Hi @sanketkhot7 

 

Could you please clarify which specific scenario you’re referring to, such as form loading, field changes, or record submission? This will help me provide a more accurate answer.

 

Tejas Adhalrao
Mega Sage

hi @sanketkhot7 ,

In ServiceNow, the execution order depends on the type of client-side and server-side script.

Client-side execution:

  1. UI Policy – onLoad actions

  2. Client Script – onLoad

  3. Client-side scripts run when the user interacts with the form, such as onChange and onSubmit.

Server-side execution when submitting a form:

  1. Before Business Rules

  2. Data is saved to the database

  3. After Business Rules

  4. Async Business Rules run asynchronously

  5. Display Business Rules run when the form is loaded, to send server-side data to the client.

Note that this is a simplified overview. UI Policies and Client Scripts can have different execution orders depending on their configuration, and Display Business Rules run before the form is rendered, not after the record is saved.

 

 check attached screenshorts.

 

If this helped, mark it helpful and accept the solution. 

Regards,

Tejas

Tanushree Maiti
Tera Patron

Hi @sanketkhot7 

 

First Refer Servicenow Documentation : Execution order of scripts and engines 

Also check community article: Servicenow 101 : Business rule, workflow and flow designer execution order.

 

For Client script -

In ServiceNow, Client Scripts execute first before UI policy but  if a Client Script and a UI Policy apply conflicting logic to the same field (e.g., the Client Script makes a field read-only or hidden, and the UI Policy makes it editable or visible), the UI Policy wins and overrides the Client Script.

 

 

yashkamde
Giga Sage

Hello @sanketkhot7 ,

 
Client side code always executes in the browser before the form is fully submitted to the server. Once submitted, a precise, structured sequence of server-side rules and database engines takes over.

Component Type

Runs On

Order Rule

Conflict Resolution

Client Scripts

Browser (Client Side)

Client Scripts and UI Policies execute according to their respective event and execution logic; there is no universal rule that Client Scripts always run first.

If both modify the same field, the final result depends on execution order and logic. UI Policies do not automatically take precedence over Client Scripts.

Business Rules

Server

Determined by the Order field and execution type (Before, After, Async, or Display).

For Business Rules in the same execution phase, lower order numbers generally execute before higher order numbers (e.g., 100 before 200). Conflicts depend on the scripts and their execution phases.


Also Refer this :

order 

 

If my response helped mark as helpful and accept the solution.