IT CanvassTalk to an advisor
Development · LessonReviewed by Neelima, ServiceNow Architect · Updated · Published · current release · beginner

ServiceNow UI policies & UI actions

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

Quick answer

A ServiceNow UI policy makes fields mandatory, visible or read-only when a condition holds, declaratively, on every form, running after client scripts and able to override them. A UI action adds a button, link or context-menu item that runs server code with current in scope, or client code with the Client checkbox. Policy for field state, action for operations.

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.

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