Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 39 ยท Forms, Lists and UI Policies

UI Policies

Make forms react without code: build UI policies with conditions and actions, understand Reverse if false, On load, Global, Order, scripts, and UI policy versus client script.

A form should adapt to what the user enters. When State is On Hold, a Hold reason should appear and be mandatory. When the caller is a VIP, a note should show. UI policies deliver this behavior in the browser, with conditions and actions you set up without writing a script.

What a UI policy is

A UI policy is a record in sys_ui_policy with:

  • a Table it applies to (and inherited children, if Inherit is true),
  • a Condition that is true or false,
  • UI policy actions (sys_ui_policy_action): one per field, each saying whether the field is Mandatory, Visible and Read only, each set to True, False or Leave alone,
  • optional Scripts for logic that needs code.

Open System UI > UI Policies and press New, or use the context menu Configure > UI Policies on a form.

Creating one

Goal: when state is On Hold, show hold_reason and make it mandatory.

  1. Table: Incident. Short description: "Hold reason when on hold".
  2. When to apply: set Conditions to State is On Hold.
  3. Keep Reverse if false checked, On load checked and Active checked.
  4. Submit, then in UI Policy Actions press New: Field name hold_reason, Mandatory True, Visible True, Read only Leave alone.

When the form loads or the state changes to On Hold the field appears and is required; when the state changes away it is reversed.

The important checkboxes

Setting What it does
Active The policy is enforced only when active
Global Apply to all form views. When unchecked, a View field limits the policy to one view
On load Also evaluate when the form opens, not only on change
Reverse if false When the condition is false, apply the opposite of each action (mandatory off, visible back)
Inherit Also apply to tables that extend this one
Order Lower numbers run first; matters when several policies touch the same field
Run scripts Shows Execute if true and Execute if false script boxes

If you leave Reverse if false off, a field made visible stays visible after the condition becomes false, which is a common bug report.

UI policy parts

Condition When does it apply?
Actions Mandatory, visible, read-only.
Reverse Undo when false.
Scripts Optional client logic.
1 / 2
Python A UI policy evaluator (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

UI policy scripts

When actions are not enough, tick Run scripts. The Execute if true and Execute if false boxes hold client-side JavaScript. A script policy can use client APIs such as g_form:

JavaScript
// Execute if true (read-only example)
function onCondition() {
  g_form.setValue('assignment_group', '');
  g_form.showFieldMsg('hold_reason', 'Explain why the work is on hold.', 'info');
}

g_form is the form object with methods like setMandatory, setVisible, setReadOnly, getValue, setValue, addInfoMessage and clearValue. Client scripting in depth is its own topic; here just know that UI policy scripts are the place for small amounts of logic tied to a condition.

UI policy versus client script

UI policy Client script
Setup Conditions and actions, no code JavaScript
Reverse handling Built in (Reverse if false) You write both directions
Triggers Condition becomes true/false, on load onLoad, onChange, onSubmit, onCellEdit
Best for Mandatory, visible, read-only toggles Complex logic, values, messages, validation

Prefer a UI policy for toggles. It is easier to read, easier to maintain and runs when conditions change. Use a client script when you need something UI policies cannot express. Avoid giving the same field conflicting rules in both places; when they conflict, the UI policy's actions are applied after client scripts have run, so the UI policy usually wins.

UI policies are not security

UI policies run in the browser and only on forms. They do not apply when records change through imports, web services, background scripts or list edits (list editing has its own ruleset). If a rule must always hold, back it with a data policy (see Data Policies) or a server-side rule, and use an ACL if the issue is permission.

Python Why a client-only rule can be bypassed (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Debugging tips

  1. Turn on Active and check the Condition. A condition on the wrong field name silently never matches.
  2. Look at Order and other policies on the same field (UI Policies list filtered by Table).
  3. Use the browser developer console and the Client Scripts / UI Policy debug tools (the Debug UI Policies option in the form context menu, where enabled) to see which fired.
  4. Test as the real role: impersonate.
  5. Check Global and View when a policy seems to apply on one form view only.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does Reverse if false do?

    When the condition stops being true the field settings are undone, so a shown field hides again.
  2. 2. Which is the best first choice to make a field mandatory when state is On Hold?

    UI policies handle mandatory, visible and read-only toggles without code and reverse automatically.
  3. 3. Why is a UI policy not enough to guarantee data quality?

    Server-side paths do not run client-side policies; use data policies or business rules.
  4. 4. What does On load control?

    With On load checked, the condition is evaluated as the form loads, not only on later changes.

Summary

  • A UI policy applies mandatory, visible and read-only actions when a condition holds.
  • Use Reverse if false, On load, Global, Inherit and Order deliberately.
  • Scripts are optional; prefer actions first.
  • Client-side only: back guarantees with data policies or server rules.

Next: Data Policies