the order of execution

Madhumitha
Kilo Explorer

which one of the following execute first?

a. business rule

b. script includes

c. ui policy

d. client script

7 REPLIES 7

Jeff Currier
ServiceNow Employee
ServiceNow Employee

From an old community post by Paul,

Field State (Mandatory,Visible, Read only) is generally applied in the following order of preference, where one is the top preference:

  1. ACL (Visible/Disabled)
  2. Dictionary Entry (Mandatory/Disabled)
  3. UI Policy (Mandatory/Visible/Disabled)
  4. Data Policy as UI   (Mandatory/Disabled)
  5. Client Script (Mandatory/Visible/Disabled)

This is the doc which covers business rules in great detail.

The order of execution is as follows:
  1. Before business rules: Scripts configured to execute before the database operation with an order less than 1000.
  2. Before engines. The following are not executed in any specific order:
    • Approval engine (for task and sys_approval_approver tables)
    • Assignment rules engine (for task tables)
    • Data policy engine
    • Escalation engine
    • Field normalization engine
    • Role engine - keeps role changes in sync with sys_user_has_role table (for sys_user, sys_user_group, sys_user_grmember, and sys_user_role tables)
    • Execution plan engine (for task tables)
    • Update version engine - creates version entry when sys_update_xml entry is written (for sys_update_xml table)
    • Workflow engine (for default workflows)
  3. Before business rules: Scripts configured to execute before the database operation with an order greater than or equal to 1000.
  4. The data base operation (insert, update, delete).
  5. After business rules: Scripts configured to execute after the database operation with an order less than 1000.
  6. After engines. The following are not executed in any specific order:
    • Label engine
    • Listener engine
    • Table notifications engine
    • Role engine - keeps role changes in sync with sys_user_has_role table (for sys_user, sys_user_group, sys_user_grmember and sys_user_role tables)
    • Text indexing engine
    • Update sync engine
    • Data lookup engine inserts or updates
    • Workflow engine (for deferred workflows)
    • Trigger engine (for all Flow Designer flows)
  7. Email notifications. The following are executed based on the weight of the notification record:
    • Notifications sent on an insert, update, or delete
    • Event-based notifications
  8. After business rules. Scripts configured to execute after the database operation with an order greater than or equal to 1000.

 

Prateek kumar
Mega Sage

You are comparing server and client side elements here. 

UI policies and Client Scripts act Client side(Browser window), so they execute first. Between these two UI policies execute first.

Business rule- Order of execution decides which acts first(Lower order execute first). Type of the business rules even decide if they act even before your browser shows you the records (before query BR)

Script Includes- They are code repository can be used from server and client side. The order of execution is decided on where you are calling the script include.

Basically, the execution order really depends on the use case you are in.

Hope this helps. Please don't forget to mark it as correct/helps as applicable.

 

 

-Cheers

Prateek kumar


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

ARG645
Tera Guru

A picture is worth a thousand words

find_real_file.png

 

You may wonder why script includes aren't mentioned in the picture. Script includes can be called from Business Rules or any other Server Side scripts. So, script includes dont have an order of execution, it depends upon which Server side entity is calling it.

 

Thank you,

Aman Gurram

Please close this thread if your question is answered. If its not answered, then please let us know your further questions.