UI Policy
The UI Policy DocType in TechMaju allows developers to dynamically change the behavior of information on a form and control custom process flows for tasks. UI policies enable users to create rules that can make fields mandatory, read-only, or hidden without any scripting. This ensures faster load times and efficient form management.
Understanding the UI Policy DocType
Purpose: The UI Policy DocType is designed to control the user interaction with forms within the TechMaju platform. It allows developers to set conditions that determine how fields should behave (e.g., read-only, mandatory, hidden) based on certain criteria.
Function: UI policies are used to dynamically change the behavior of fields on a form. UI policies evaluate all fields even if they are not visible on the form, eliminating the need for fields to be present on the form for evaluation. UI policies do not require any scripting, if complex actions are needed then use client script instead.
UI policies can be applied to forms enabling custom behaviors and interactions based on client-side events. UI Field Policies are field properties that can be set on a field for when an user is interacting with the form. The UI field policies is set by choosing 'Yes' or 'No' to configure the behavior of the specified field based on the trigger condition. The available UI field policies are:
Display: Making fields visible or hidden
Required: Making fields mandatory or optional
Read only: Making fields read-only or writable
Clear value: Clear field value when the condition evaluates to true or false
Role Required
TM Core Developer: Can create, write, and delete UI Policies.
UI Policy Fields
Field | Description |
|---|---|
Name | The name of the UI Policy. |
DocType | The DocType to which the policy will be applied. |
Application | The application where the policy will be used. |
Active | A checkbox to activate or deactivate the policy. |
Reverse if false | Reverse UI field policies when conditions are false. |
On load | Apply UI field policies on form load. |
Filter Conditions | Conditions that determine when this policy is triggered. |
UI Field Policy | Field properties to determine how the user will interact with the form:
|
Procedure
Navigate to Develop > UI Policy.
Adding a New UI Policy:
Click on '+ Add UI Policy' to open the creation form.
Fill in the required fields: Name, DocType, Application.
Check the 'Active' checkbox if you want the policy to be active immediately.
Optionally, check 'Reverse if false' to reverse the policy when conditions are false.
Optionally, check 'On load' to apply the policy on form load.
Define the filter conditions to set when this policy is triggered.
Under 'UI Field Policy', set the properties to determine how the user will interact with the form, such as making fields read-only, mandatory, or hidden.
Configuring the UI Policy:
Adjust the filter conditions and UI Field Policy settings as needed to fit the specific requirements of the DocType and the form behavior.
Use the 'Add a Filter' option to specify multiple conditions if necessary.
Use the 'Add Row' option to define multiple field policies.
Saving and Viewing the UI Policy:
Click on 'Apply' to save the UI Policy.
The policy will be executed in the specified context (form) whenever the corresponding conditions are met.
Best Practices
Ensure the out of box DocType Form view functionalities does not conflict with custom UI Policies.
Use UI policies over UI Scripts for easier maintenance and manageability.