Which one I should choose? UI policy or client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 12:38 PM
I would like set some fields visible condition. I have to use the script to set up visible condition if I use UI policies to call other tables. I would like to know is there any performance difference use the script in UI policies and use the script in client script?
Thanks,
Faye

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 04:15 PM
As people said you should use UI policies instead of client scripts, another thing to be considered is client script may not work for new SN upgrade and you have to revisit and modify (e.g. changing DOM in new SN release, API, etc.).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 05:21 PM
There are actually 4 different ways to control field visibility in ServiceNow, that all have different uses, performance and applications.
They can be seen below in order of best performance to worst. This is not necessarily the order of preference as each has valid uses in different scenarios.
Method | Performance | Use when |
---|---|---|
Views | The field is never rendered in the browser with if it is not included on the view. | You want users to be able to view the field from a list but never on a form. |
ACL | If the user has no read access to the field, the field will never show on the form. | You want users to never see the field in lists, forms, or anywhere in the tool. |
Client Scripts (g_form.setVisible) | OnLoad Client Script run before UI Policy | The triggering logic of the field visibility i cannot be expressed in the UI Policy condition builder. |
UI Policy | Field is rendered and then hidden as the form loads. | Field visibility needs to be toggled, depending on simple logic. |
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022