UI policy vs data policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2024 10:51 AM
could any one please exlpain me difference between UI policy and data policy with use case?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2024 10:56 AM
Hi there,
This is a typical question Chat GPT could give you a quick answer for. For example:
UI Policy
Definition: UI Policy in ServiceNow is used to dynamically change the behavior of fields and form sections on the client-side (i.e., in the user's browser). This means that UI Policies are triggered when a user interacts with a form and can change the visibility, read-only status, or mandatory status of fields in real-time.
Use Case: Suppose you have a form for creating an incident record. You want to make the "Resolution Notes" field mandatory only when the incident state is set to "Resolved".
Steps:
- Create a UI Policy for the Incident table.
- Set the condition: When the "State" field is "Resolved".
- Add a UI Policy Action to make the "Resolution Notes" field mandatory.
- Save the policy.
When a user sets the incident state to "Resolved" while filling out the form, the "Resolution Notes" field will immediately become mandatory, ensuring that the user cannot submit the form without filling out that field.
Data Policy
Definition: Data Policy in ServiceNow is used to enforce data integrity and control field values at the server-side. Data Policies apply to all data operations (UI, Import Sets, Web Services, etc.), ensuring that certain conditions are met before data is saved to the database.
Use Case: Imagine you need to ensure that a short description is always provided for incident records, regardless of how they are created (e.g., through the UI, via an import set, or an API).
Steps:
- Create a Data Policy for the Incident table.
- Set the condition: None (apply always).
- Add a Data Policy Rule to make the "Short Description" field mandatory.
- Save the policy.
Whenever an incident record is created or updated, the Data Policy will enforce that the "Short Description" field is populated. If someone tries to create or update an incident without a short description, the operation will be rejected.
Key Differences
-
Scope:
- UI Policy: Affects forms and is enforced in the user's browser.
- Data Policy: Affects data integrity on the server-side and applies to all data operations.
-
Use Case Example:
- UI Policy: Making a field mandatory based on another field's value in real-time on the form.
- Data Policy: Ensuring a field is always populated regardless of how the record is created or updated.
-
Application:
- UI Policy: Runs only when a user interacts with a form in the UI.
- Data Policy: Runs on any data transaction, including import sets, web services, and direct database operations.
Example Scenario
Consider a scenario where you have a "Change Request" form with a "Change Type" field. Depending on the selected "Change Type," different fields need to be mandatory.
With UI Policy:
- If the "Change Type" is "Emergency," make the "Justification" field mandatory immediately as the user selects "Emergency" in the form.
With Data Policy:
- Ensure that the "Justification" field is mandatory for "Emergency" changes even if the change request is created via an import set or API, not just through the UI.
By using both UI Policies and Data Policies, you can ensure a seamless user experience while maintaining robust data integrity across all platforms and data inputs.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2024 11:01 AM
Hi @ShwetaS,
In ServiceNow, both UI Policies and Data Policies are used to control and manage data, but they serve different purposes and operate in different contexts.
UI Policy
Definition:
A UI Policy is used to dynamically change the behavior and appearance of fields on a form based on user interaction. It controls the client-side behavior.
Key Characteristics:
- Operates on the client side (browser).
- Can show/hide fields, make fields mandatory/optional, and enable/disable fields.
- Immediate effect as users interact with the form.
- Works only on the UI forms.
Use Case:
Let's say you have an Incident form where you want to show the "Urgency" field only if the "Impact" field is set to "High". You can create a UI Policy that:
- Condition: If "Impact" is "High"
- Action: Show the "Urgency" field
This provides immediate feedback to the user filling out the form.
Data Policy
Definition:
A Data Policy is used to enforce data integrity rules regardless of how the data is entered into the system. It controls the server-side behavior.
Key Characteristics:
- Operates on the server side.
- Ensures data consistency and integrity.
- Applied to all data entry points: forms, web services, import sets, etc.
- Can be used to make fields mandatory or read-only.
Use Case:
Consider you have a requirement that the "State" field on the Incident table must always have a value. You can create a Data Policy to enforce this rule:
- Condition: None (applies universally)
- Action: Make the "State" field mandatory
This ensures that any data entry method, whether through forms, APIs, or import sets, must have the "State" field filled out, maintaining data integrity.
Summary
- UI Policy: Client-side, for dynamic form behavior, immediate effect, limited to UI forms.
- Data Policy: Server-side, ensures data integrity, applies universally to all data entry methods.
If this answer was helpful, I would appreciate if you marked it as such - thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2024 11:16 AM
Hi @ShwetaS
The Data Policy and UI policy both implement data regularity by putting the filed attributes on the basis of certain conditions. Data policy gets executed in server- side and UI policy gets executed on client side. DATA POLICY implements data regularity by keeping as mandatory or read only field attributes. The UI policy logic gets applied to data entered in the form whereas the data policy logic gets executed no matter how a record changes. Scripts cannot be applied to Data policy.
Creating a data policy:
Step1: Go to the Create application file link
Step 2: Choose file type, for this case use DATA POLICY
Step 3: Configure the newly created file
Data policy gets triggered on the basis of conditions and they can take different actions as the conditions evaluates to true or false also we don’t need any script code to set the fields as mandatory or read only. Data policies largely similar to UI policies, but the UI policies gets applied to data that is entered inside the form through any browser. Whereas the data policy can be applied to any kind of data entered in the ServiceNow system, including the data that is being imported from the foreign sources like through import sets, web services etc.
We can convert Data Policy into UI Policy and vice versa. ON the UI policy form we can find a UI action button called convert this to the Data policy. Clicking this button will automatically generate a new data policy and will automatically take you to the form that will be displaying the new record, and from data policy to UI policy we will have to navigate to System Policy à Rulesà Data Policies, and then click the existing Data Policy, under the Related Links we will find a Convert this to UI Policy by clicking that a new UI policy record will appear, after that we need to edit the fields in it as we need them.
UI policies are client side functions that work on form and behaviour of form fields in UI policies we do not always need scripting.
UI Polices are used to make form field mandatory, visible and read only.
Mark it Helpful and Accept Solution!! If this helps you to understand.