Skip to content
Tutorials Center
My learning

Topics

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

Data Policies

Use data policies to enforce mandatory and read-only fields on the server for forms, imports and web services, and learn how they differ from UI policies and ACLs.

A UI policy makes a form behave well, but the data can still arrive another way: a spreadsheet import, a REST call from another system, a script. A data policy enforces the same kind of rule where all paths meet, on the server. It is the tool for "this must be true, no matter how the record got here".

What a data policy does

A data policy (table sys_data_policy2) has a Table, a Condition and a list of rules (sys_data_policy_rule), one per field. Each rule can set a field as:

  • Mandatory: the record cannot be saved with it empty, or
  • Read only: the field cannot be changed.

That is all: data policies do not hide fields or run scripts. That limit keeps them simple and fast. The conditions use the same condition builder as filters.

Open System Policy > Rules > Data Policies and press New.

Where it applies

Checkboxes on the policy decide the paths covered:

Setting Effect
Apply to import sets Enforced when loading data through import sets and transform maps
Apply to SOAP / web services Enforced for inbound API calls (the label differs between releases; it covers inbound web service requests)
Use as UI policy on client Also behaves like a UI policy in the browser, so users see the mandatory/read-only state before saving
Reverse if false Applies the opposite when the condition stops being true
Inherit Applies to child tables
Active The policy is enforced

When Use as UI policy on client is ticked, the platform creates the matching client behavior for you, which gives the best experience: the user sees the red asterisk, and the server still refuses bad data from other sources. When you convert a UI policy into a data policy, the tool tells you if the policy has scripts or visibility actions that cannot be converted.

Walkthrough

Goal: a resolved incident must always have a resolution code, from any source.

  1. System Policy > Rules > Data Policies > New.
  2. Table: Incident. Conditions: State is Resolved.
  3. Tick Use as UI policy on client, Apply to import sets and the web-service option.
  4. Submit, then add a Data Policy Rule: field close_code, Mandatory True.
  5. Test: resolve an incident on the form without a code (blocked, asterisk visible), then try an inbound API update that omits it (rejected with an error).
Python Server-side enforcement on every path (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.

Data policy versus UI policy versus ACL

Question Tool
Show, hide or require a field while someone edits a form? UI policy
Must a field always be filled, from forms, imports and APIs? Data policy
May this user read or change this table, record or field at all? ACL
Need to calculate, copy or reject using code? Business rule (server script)

A well-built process often uses several: a UI policy for the nice behavior, a data policy as the guarantee and an ACL for permission.

Python Pick the right tool (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.

Gotchas

  • Existing bad data. A new mandatory data policy does not fix old records, but saving an old record that violates it will fail. Clean data first, or limit the condition.
  • Imports. With Apply to import sets the whole row is rejected on a violation, so test transform maps after adding a policy.
  • Order of rules. Data policies and dictionary-level mandatory both exist. A dictionary mandatory flag always applies and cannot be conditional; a data policy is conditional.
  • Read-only is not security. A read-only data policy prevents changes through the covered paths, but it does not hide data. Use ACLs for visibility and for permission to write.
  • Scripts: if you need logic, use a business rule. Data policies have none.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. What can a data policy rule enforce?

    Data policies set fields mandatory or read-only on the server; they do not hide fields or run scripts.
  2. 2. Why use a data policy instead of only a UI policy?

    UI policies only run in the browser form; data policies are enforced on the server for other paths.
  3. 3. Which tool controls who may read a field?

    ACLs decide permission; hiding a field with a view or UI policy does not secure it.

Summary

  • Data policies enforce mandatory and read-only server-side, even for imports and APIs.
  • Tick Use as UI policy on client to get the form experience too.
  • Choose UI policy for form behavior, data policy for guarantees, ACL for permission, business rule for code.
  • Test with existing data and import transforms.

Next: UI Actions and Form Buttons