order of precedence over a field

mcclain
Mega Contributor

Q6. What is the order of precedence over a field? ACL or UI policy or Client Script? I am bit confused while implementing on a particular field.

1 ACCEPTED SOLUTION

Shishir Srivast
Mega Sage

Hi McClain,



They all are created for different purpose. Please don't get confused with each other.



ACL - Purpose of this is to ensure what data users can access and how they can access it


Client Script - This is for Client side (or browser side) validation. Client side validation includes, making a field mandatory, read-only, hidden etc. This will get applied only at the browser.


UI Policy - This is similar to Client Script, except that not need to write a script


Business Rule. This script runs at the server side when a form Insert, Update etc. This can do some action that can be achieved only by running from Server.



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)


Examples:


If the user does not have write access to a field (ACL), a UI Policy to make it editable will do nothing.


If a field is set to disabled on a Dictionary Entry, a UI Policy to make it mandatory or editable disabled will do nothing.


If a field is made read only by a Client Script, a UI Policy to make it editable will take preference.


3,4 or 5 may be variable based on order.



Reference: Hierarchy of Client Script, UI Policy and Business Rule and ACL



Please let me know if response is good enough to proceed further. Please provide your feedback to help community.


View solution in original post

4 REPLIES 4

Shishir Srivast
Mega Sage

Hi McClain,



They all are created for different purpose. Please don't get confused with each other.



ACL - Purpose of this is to ensure what data users can access and how they can access it


Client Script - This is for Client side (or browser side) validation. Client side validation includes, making a field mandatory, read-only, hidden etc. This will get applied only at the browser.


UI Policy - This is similar to Client Script, except that not need to write a script


Business Rule. This script runs at the server side when a form Insert, Update etc. This can do some action that can be achieved only by running from Server.



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)


Examples:


If the user does not have write access to a field (ACL), a UI Policy to make it editable will do nothing.


If a field is set to disabled on a Dictionary Entry, a UI Policy to make it mandatory or editable disabled will do nothing.


If a field is made read only by a Client Script, a UI Policy to make it editable will take preference.


3,4 or 5 may be variable based on order.



Reference: Hierarchy of Client Script, UI Policy and Business Rule and ACL



Please let me know if response is good enough to proceed further. Please provide your feedback to help community.


Thanks Shishir. Your reply is very informative.



Regards,


Mcclain


chirag_bagdai
ServiceNow Employee
ServiceNow Employee

Hello McClain,



The execution order is :


1.Server side script - ACL


2. Client side scripts :


First onLoad Client scripts, after that the first UI Policies kick in.


After that, the Client scripts and UI Policies that work onChange.


After that, the Client scripts that work onSubmit.



You can find more information from below threads:


What will run first business rule or client script?


Execution order of scripts and engines


Thanks Chirag.



Regards,


Mcclain