IT CanvassTalk to an advisor
Development · LessonBy , ServiceNow Architect · Published · current release · beginner

UI policies & UI actions

Control form behaviour without code, and add buttons that run logic.

Quick answer

UI policies and UI actions are two of the most-used configuration tools on the platform. A UI policy changes how a form behaves, which fields are mandatory, visible or read-only, declaratively, no code required. A UI action adds a button, link or context-menu item that runs logic when clicked.

Key takeaways
  • UI policy: no-code form control
  • UI action: buttons that do things
  • When to use which
  • Try it Yourself

UI policies and UI actions are two of the most-used configuration tools on the platform. A UI policy changes how a form behaves, which fields are mandatory, visible or read-only, declaratively, no code required. A UI action adds a button, link or context-menu item that runs logic when clicked.

UI policy: no-code form control

Define a condition (e.g. Category is Hardware) and the platform enforces the resulting field states automatically, on the client, everywhere the form appears. UI policies run after and can override client scripts, so prefer them for simple show/hide/mandatory.

UI policy vs data policy. A UI policy acts on the form in the browser. A data policy enforces the same rules at the database level, so imports and API writes obey them too. Build a data policy first, then 'convert' it to a UI policy for the on-screen experience.

UI action: buttons that do things

A UI action can run on the client, the server, or both. The Client checkbox plus an onClick function runs browser code; leaving it server-side runs a script with current in scope.

// Server-side UI action: "Escalate" button current.priority = '1'; current.work_notes = 'Escalated via UI action by ' + gs.getUserName(); current.update(); action.setRedirectURL(current);

When to use which

  • UI policy, field must be mandatory/hidden/read-only under a condition.
  • UI action, user needs to trigger an operation (approve, escalate, generate).
  • Client script, you need custom logic on load/change that a UI policy can't express.
Try it YourselfJavaScript
▸ Press Run to execute.

Runs in a sandbox in your browser. Mock gs and GlideRecord and sample data are provided.

Practice challenge

+0 XPStreak ×0
Question 1 of 3
A UI policy requires...

Frequently asked questions

What does the term UI policies & UI actions refer to in ServiceNow?
UI policies and UI actions are two of the most-used configuration tools on the platform. A UI policy changes how a form behaves, which fields are mandatory, visible or read-only, declaratively, no code required. A UI action adds a button, link or context-menu item that runs logic when clicked.
What else is worth knowing about UI policies & UI actions?
Category is Hardware) and the platform enforces the resulting field states automatically, on the client, everywhere the form appears.
What is the practical takeaway on UI policies & UI actions?
UI policies run after and can override client scripts, so prefer them for simple show/hide/mandatory.
Practise this on your own free instance.
Set up your free instance →
Already working on ServiceNow and stuck on a live ticket?Get an expert ServiceNow developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support