- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2019 08:50 AM
Hello All,
I am new to ServiceNow, I am studying UI Policy and Client Scripts.
I know they both runs on Client side, Can some one please give me a real life use case scenarios, Ex : [ where to use what ]
If possible, can you please provide me multiple use case scenarios.....
i was following this article ::
Thank You...
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2019 09:28 AM
Real Time Scenario :
UI Policy : if you want to make your form field "Mandatory" "Read Only" "Visible" based on some field condition or browser load then you can simply use UI Policy here.
Let's take an example : i want to make work notes field mandatory based on the state field value. so this is a simple straight forward requirement. so here i will go with UI Policy.
i will Create an UI Policy and set the filter condition State | IS | Resolved then in the UI Policy action i will set true for Work notes field.
If you have a similar requirement but the work notes field should be mandatory on form Submission then you have to use here onSubmit Client script because in UI Policy you can either set it on field change or form load ( only in these two scenario you can run the UI Policy ).
But Client script can be run on either onLoad() , onChange() , onSubmit() or onCellEdit().
Now Coming to the Client SCript:
if you have a scenario here , to populate some field value in short description field. example:
I want to set CAller title in to the short description then here you can write onChange() client script on caller field to get the caller title value and set into the short description field.
Now you compare the first example and the second example, you will see the complexity in the requirement.
this way you can decide on which scenario you should use UI Policy and Client Script.
I am adding one TechNow Episode here . this is specific to the client script.
TechNow Episode 5 | Client-Side Scripting Fundamentals

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2019 09:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2019 09:06 AM
Hi,
Hope the following link will help you:
https://community.servicenow.com/community?id=community_blog&sys_id=512d26e5dbd0dbc01dcaf3231f9619ce
Mark it as correct/heplful,if it helps.
Regards,
Ragini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2019 09:07 AM
Hi
Client script:Client scripts are shipped to the client (the browser) and run there instead of on the server. Users who know JavaScript can define scripts to run in the client browser
UI policy:UI policies offer an alternative to client scripts for dynamically changing information on a form. Administrators and users with the Personalize Rules [personalize_rules] or the UI policy administrator [ui_policy_admin] role can use UI policies to define custom process flows for tasks.
NOTE:As a best practice always use UI policy if you want to make field to be hidden,readonly,Mandatory
You can go with UI policy incase of onLoad and onChange and you can also use the script based on true and false conditions.
Client Scripts vs. UI Policies
Client Scripts and UI Policies both execute client-side logic and use the same API. Both are used to manage forms and their fields. When developing an application, how can you decide which client-side script type to use? Use this table to determine which type is best suited to your application's needs:
Criteria | Client Script | UI Policy |
---|---|---|
Execute on form load | Yes | Yes |
Execute on form save/submit/update | Yes | No |
Execute on form field value change | Yes | Yes |
Have access to field's old value | Yes | No |
Execute after Client Scripts | No | Yes |
Set field attributes with no scripting | No | Yes |
Require control over order of execution | *Yes | Yes |
Your understanding is correct regarding the client script.
Please go through the below link to know what is the difference among script
1) http://wiki.servicenow.com/index.php?title=Differences_Among_Scripts
2) http://jamesn903.files.wordpress.com/2014/04/15lb3-scripting201.pdf --> Some pages of this would be helpful.
3) Wizard UI Policy and Client Scripts - ServiceNow Wiki
https://community.servicenow.com/community?id=community_question&sys_id=53b70be9db1cdbc01dcaf3231f961916
https://community.servicenow.com/community?id=community_blog&sys_id=512d26e5dbd0dbc01dcaf3231f9619ce
Please mark reply as Helpful/Correct, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2019 09:28 AM
Real Time Scenario :
UI Policy : if you want to make your form field "Mandatory" "Read Only" "Visible" based on some field condition or browser load then you can simply use UI Policy here.
Let's take an example : i want to make work notes field mandatory based on the state field value. so this is a simple straight forward requirement. so here i will go with UI Policy.
i will Create an UI Policy and set the filter condition State | IS | Resolved then in the UI Policy action i will set true for Work notes field.
If you have a similar requirement but the work notes field should be mandatory on form Submission then you have to use here onSubmit Client script because in UI Policy you can either set it on field change or form load ( only in these two scenario you can run the UI Policy ).
But Client script can be run on either onLoad() , onChange() , onSubmit() or onCellEdit().
Now Coming to the Client SCript:
if you have a scenario here , to populate some field value in short description field. example:
I want to set CAller title in to the short description then here you can write onChange() client script on caller field to get the caller title value and set into the short description field.
Now you compare the first example and the second example, you will see the complexity in the requirement.
this way you can decide on which scenario you should use UI Policy and Client Script.
I am adding one TechNow Episode here . this is specific to the client script.
TechNow Episode 5 | Client-Side Scripting Fundamentals