The CreatorCon Call for Content is officially open! Get started here.

Which one I should choose? UI policy or client script

fayexhz
Kilo Contributor

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

6 REPLIES 6

manducchau
Mega Guru

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.).


The SN Nerd
Giga Sage
Giga Sage

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.



MethodPerformanceUse 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.
ACLIf 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 PolicyThe triggering logic of the field visibility i cannot be expressed in the UI Policy condition builder.
UI PolicyField 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