UI policies and client scripts
ServiceNow CSA · Lesson 22 of 24 · 2:39:31
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the ServiceNow Certified System Administrator (CSA) exam. In this lesson: UI policies and their actions, UI policy options (Reverse if false, On load, Global, Inherit, and Order), data policies, and client scripts (onLoad, onChange, onSubmit, and onCellEdit). Includes three original practice questions, with Brackenridge Engineering, a fictional engineering firm whose IT team runs its ServiceNow instance, as the example.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Close notes, every time
Brackenridge's resolved incidents keep arriving without close notes. The service desk wants the field to become mandatory as soon as an agent resolves an incident, without writing code if possible. UI policies, data policies, and client scripts each have a part to play.
UI policies
A UI policy changes the behavior of a form dynamically, by making fields mandatory, read-only, visible, or hidden, when its conditions are met. Basic UI policies need no scripting: admins create them under System UI, then UI Policies, with the UI policy admin role, and build their conditions with the condition builder. Each UI policy action sets a field's Mandatory, Visible, and Read only states to True, False, or Leave alone. Conditions are rechecked only when a user changes a field on the form, not when a UI action or the list editor changes the record. And since client scripts can do the same things, ServiceNow recommends UI policies whenever possible, because forms load faster.
UI policy options
Reverse if false undoes the actions of the policy when its conditions become false again. On load also applies the policy when the form loads, and not only when a field changes. Global applies the policy to every view of the form, and clearing it lets you choose one view. Inherit lets tables that extend this table use the policy, and when two policies conflict, the one with the higher order number runs last, and wins. And Run scripts adds a script for when the conditions are true, and another for when they are false.
Data policies
UI policies only apply to data entered on a form, in the standard browser interface. A data policy enforces mandatory and read-only rules on all data, including data from import sets, web services, and the mobile interface. Data that breaks a data policy produces an error, and the record is not saved. Selecting Use as UI Policy on client also applies the data policy on forms, but data policies cannot hide fields, so they complement UI policies rather than replace them. And admins find them under System Policy, then Data Policies.
Client scripts
A client script runs JavaScript in the user's browser, to improve forms based on what users enter, but it provides no data security. An onLoad script runs when the form loads, and an onChange script runs when a specific field changes, and also when the form loads. An onSubmit script runs when the form is submitted, and it can validate the values, or cancel the submission. Client scripts do not run on lists, except onCellEdit scripts, which run when a cell is edited in a list. And they use the g form API to set values, show messages, or make fields mandatory, while their UI type decides where they run.
Recap
Let's recap. UI policies make form fields mandatory, read-only, visible, or hidden, with no code, and ServiceNow prefers them to client scripts. Reverse if false undoes their actions, On load runs them when the form loads, and Global covers every view. Data policies enforce mandatory and read-only rules on all data, including imports and web services. Client scripts run in the browser, as onLoad, onChange, onSubmit, or onCellEdit scripts. And they use the g form API, for logic that a condition alone cannot express.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
A UI policy makes Close notes mandatory when an incident’s state is Resolved. If the agent changes the state back, the field must become optional again. Which option does this?
- On load
- Global
- Reverse if false
- Inherit
Show the answer
Reverse if false
Reverse if false undoes the policy's actions when its conditions become false. “On load” only decides whether the policy also runs when the form loads. “Global” decides which views of the form the policy applies to. And “Inherit” lets tables that extend Incident use the policy.
Partners resolve Brackenridge’s problems through a web service, and close notes must be required there too. A UI policy already covers the form. What should the admin add?
- A data policy on Problem
- On load, on the UI policy
- An onSubmit client script
- Global, on the UI policy
Show the answer
A data policy on Problem
A data policy applies its rules to all data, including web services, while UI policies only apply to forms. “On load, on the UI policy” would still only apply on forms in the browser. “An onSubmit client script” runs in the browser too, so web services never trigger it. And “Global, on the UI policy” changes which form views the policy covers, not where the data comes from.
Brackenridge wants a warning message to appear the moment an agent sets an incident’s priority to Critical, before anything is saved. What fits?
- An onLoad client script
- An onSubmit client script
- A data policy on Incident
- An onChange client script on Priority
Show the answer
An onChange client script on Priority
An onChange client script runs in the browser as soon as the Priority field changes. “An onLoad client script” only runs when the form loads, not when the field changes. “An onSubmit client script” waits until the form is submitted, which is later than the moment the field changes. And “A data policy on Incident” applies rules to saved data, and it cannot show a message as the field changes.