Entity validation rules
Entity validation rules define custom rules and limitations for updating a WorkZone entity (a case, a contact, a document, or a custom type). Using entity validation rules, you can disable or restrict the possibility of updating an entity, until specific criteria are met. For example, you can disable the possibility to close cases that contain any non-archived documents, or to make it mandatory for all documents to have a letter date. See Example: below for a more detailed overview.
Entity validation rules, along with the validation triggers, are defined in the entity validation rulesets.
- An entity validation ruleset: a set of validation triggers and validation rules for an entity.
- A ruleset (validation) trigger: a set of conditions that define when to check the validation rule.
- A validation rule: an OData filter query that defines custom requirements or limitations for an entity update.
Entity validation rulesets will apply to the singular entity edits and the mass-editing of multiple entities at once. You can create entity validation rulesets for any kind of entity updates, and combine multiple rules and triggers, as long as they do not contradict each other. Additionally, you can:
- Define whether the users will be able to continue with updating the entity, if its validation rule results in an error.
- Provide custom messages for each validation rule (and localize these messages into your supported languages).
- Scenario 1: You want all of your terminated contacts to have a termination reason. To achieve that, you can add a custom property on contacts with the code RFE and the name Termination reason, and then create an entity validation rule for contacts, which would state that inserting an End date for a contact (that is, terminating that contact) should only be allowed, if the Termination reason field is not empty (in the Entity validation ruleset dialog, add a Ruleset trigger:
EndDate Does not equal null
, Rule template:Contacts/$count?$filter=ID eq '${Context.ID}'and RFE_Value ne null
, and Condition:Equals 1
). Additionally, you can provide an error message saying that users must enter a termination reason before adding an end date. - Scenario 2: You want to prohibit closing the cases that contain any non-archived documents. To achieve that, you can create an entity validation rule for cases which would check upon case closure if all documents on that case are in the Archived state (in the Entity validation ruleset dialog, add a Rule trigger:
Closed Does not Equal null
, Rule template:Files('${Context.ID}')/FileRecords/$count?$filter=State_Value ne 'ARK'
, and Condition:Equals 0
). Additionally, you can provide an error message saying that users must archive all documents on a case, before closing that case.
Entity validation rules will use the current entity context, including even the most recent user input that has not been saved to the database yet.
Create an entity validation ruleset
- On the start page, click Client.
- Select the Entity validation rules tab.
- From the droplist at the top, select the entity type for which you want to define validation rules.
- Click Create. The Create entity validation ruleset dialog opens.
-
Fill in the following fields:
- Ruleset label: Provide unique name for this validation ruleset.
- Ruleset trigger: Click + Add trigger to define an update event for running this validation ruleset (that is, a set of conditions that define when to check the validation rule).
- From the droplist, select Entity property (this droplist is generated based on your entity type selection from step 3).
- From the droplist, select Condition to apply (Equals, Does not equal, Greater than, Greater or equal, Less than, Less or equal, Contains, Starts with, and Ends with).
- Value: Enter the needed value (supported variables: @Me, @Unit, @Authority, @Day, @Week, @Month, @Quarter, @Year).
Tip: For the @Day value you can use numeric modifiers with + and -. For example: @Day+1 (tomorrow), @Day-1 (yesterday), @Day+2m (two months in the future), @Day-3y (three years in the past), and so on.
- Validation rules: Click + Add rule to add one or more validation rules for this ruleset.
- Rule template: Enter the validation rule in form of an OData filter query with your custom requirements or limitations for an entity update. For example: Files('${Context.ID}')/FileRecords/$count?$filter=State_Value ne 'ARK'. See Querying data with OData for more information about OData queries.
- From the droplist, select Condition to apply (Equals, Does not equal, Greater than, Greater or equal, Less than, Less or equal, Contains, Starts with, and Ends with).
- Value: Enter the needed value (supported variables: @Me, @Unit, @Authority, @Day, @Week, @Month, @Quarter, @Year).
Tip: For the @Day value you can use numeric modifiers with + and -. For example: @Day+1 (tomorrow), @Day-1 (yesterday), @Day+2m (two months in the future), @Day-3y (three years in the past), and so on.
- Continue on error: Enable this option to allow users update the entity, even if the validation rule results in an error.
- Localized rule message: Enter an error message to show the users, if this validation rule results in an error. Expand to enter the localized messages for your supported languages.
- Optionally, select Start date and End date for this ruleset.
- Click Create.
Edit a validation ruleset
- Select a validation ruleset that you want to edit.
- Click Edit.
- Apply the required changes in the Entity validation ruleset dialog.
- Click Save.
Delete a validation ruleset
- Select a validation ruleset that you want to delete.
- Click Delete, and then click Delete.