Adding Validation Rules to Entities
  • 24 Aug 2021
  • 5 Minutes to read
  • Dark
    Light
  This documentation version is deprecated, please click here for the latest version.

Adding Validation Rules to Entities

  • Dark
    Light

Article summary

Overview

A Folder Entity can have validation applied, set up in the form of Rules or a Flow created by the Entity's Action Folder. Setting up Validation Rules is particularly useful if the Action Menu is to be used to manually add an Entity rather than creating the Entity by executing a Flow. A user can emulate the Rules set up in a Flow that creates the same Entity, for example, using the Advanced Validation Rule, Validation Flow, and Validation Rule options.

config-valid-rule.jpg

Advanced Validation Rule:By default, set to data return Rule, returning data of type ValidationIssue. A user can get more sophisticated in their validation using this type; for example, using either Warn or Fatal error levels and providing a custom error message. 
Validation Rule:By default, set to a logical Rule. This rule enforces a true/false evaluation when creating an Entity. 
Validation Flow:A Flow is used to enforce the validation. For example, a database lookup to see if the vendor exists in the corporate "vendors" database before submitting a bid for a project. 

Example

This example will create a simple rule to validate that an "Income" field is greater than $1,000. This example assumes a Folder Entity called "All Applications" already exists, which is used to submit an application for insurance approval. Its properties are:

  1. The only existing validation on the Add ApplicationInfo screen is for requiring EntityName. 
  2. A simple Rule will be added to enforce a minimum quote amount of $1,000. 
  3. Navigate to the Actions Folder for the Entity, which in this example, is under Insurance Application Design > ApplicationInfo >  Entity Actions.
  4. The Add Applicationinfo screen above is what appears when the Add > Entity [User Defined] > ApplicationInfo option is selected.
  5. The only existing validation on the Add ApplicationInfo screen is for requiring EntityName. 
  6. Click on Validation Rule > Validation Rule.

  7. Name the Rule and click CREATE.

  8. By default, the Rule input data is set to the Entity, therefore it is not necessary to specify input data for the Rule to evaluate in this example.

  9. Expand Entity and select Income[ExtensionData]. Click NEXT.

  10. Expand Number Rules and select Greater Than Or Equal To, and click NEXT.

  11. Lastly, type 1000 in the Value field and click DONE.

  12. Save and close the Rule.
  13. Back in the Portal, navigate to a Folder that has the Entity Action for adding the Entity for which the Rule was established. 
  14. Click the Add option for the Entity.
  15. Notice at the bottom the new validation for Quote Amount. The entity cannot be added until the Rule evaluates true, therefore enforcing the minimum dollar amount.

Advanced Rule Example

This example will create an advanced Rule to validate that an "income" field is greater than $1,000. The difference between the advanced Rule and the simple Rule in the first example is that the Advanced Rule produces a custom error message.

Note
If you created the first Rule, delete that Rule prior to building this one since they both evaluate the same field.

This example assumes a Folder Entity called "All Applicants" already exists, which is used to submit a healthcare application. Its properties are: 

  1. The Add ApplicationInfo screen above is what appears when the Add > Entity[User Defined]option is selected.

  2. The only existing validation on the AllApplications screen is for requiring EntityName. 
  3. A simple Rule will be added to enforce a minimum quote amount of $1,000. 
  4. Navigate to the Actions Folder for the Entity, which in this example, is under Insurance Application Design > Application Configuration.
  5. Click on Validation Rule > Advanced Validation Rule.

  6. Name the Rule and click OK.

  7. Notice the difference in the properties, compared to the simple type of Rule.

  8. The Rule Type is set to Data Return Rule, and there are options for output data for both the false and true evaluations of the Rule. 
  9. The output data type is ValidationIssue, which includes the following properties:

  10. In the Start Rule window, select Add New Rule Step.
  11. Expand Entity and select Income. Click NEXT.

  12. Expand Number Rules and select Greater Than Or Equal To, and click NEXT.

  13. Lastly, type 1000 in the Value field and click DONE.

  14. Next, set the true and false data to return. In this example, use constant data. 
  15. Under the Then section's Else Return, select the mapping type Constant
  16. Click the Add New button, and enter the following:

    Details:Can be left blank, and is simply a description field for the Rule Entity.
    Level:Either Warn or Fatal. Warn would alert the user, but allow the Action on the Entity to proceed. Fatal does not let the Action proceed until the Rule evaluates true.
    Reason:This is the message that appears to the user after the Rule is evaluated. 
    Reference Property:This is the name of the Entity.[property] being evaluated. 
    Source:This can be left blank. By default, this is a System.Object. This field is relevant if there are  editable properties of the object.
  17. Leave Then > Return mapping value Null, since there does not need to be an Action for when the Rule evaluates true.

  18. Save and close the rule.
  19. Back in the Portal, navigate to a Folder that has the Entity Action for adding the Entity for which the Rule was established.
  20. Click the Add option for the Entity.
  21. Notice the new validation for Quote Amount. The Entity cannot be added until the Rule evaluates true, therefore enforcing the minimum dollar amount.

Custom Validation Flow Example

In this example, a validation Flow is used to see if the vendor exists in the company database. If not, the vendor is not permitted to provide a quote. Placeholder components are used in the Flow to simulate the database lookup. This example assumes a Folder Entity called "All Applications" already exists, which is used to submit applications for approval. Its properties are:

  1. Navigate to the Actions Folder for the Entity, which in this example, is under Insurance Application Design > ApplicationInfo Configuration.
    Click on Validation Rule > Validation Flow.

  2. Name the Rule and click OK.

  3. The Flow is automatically configured with the Entity input data. Conceptually, the database lookup would resemble:

  4. The Done path represents the existence of an applicant and is therefore connected to the Valid path. The validation on the Entity will pass when this path it takes. 
  5. The Failed path represents the applicant does not exist in the database. Therefore it is connected to the Invalid End step. 
  6. Click on the Invalid step. Notice the Output data by default is ValidationIssues.
  7. Under Inputs > Validation Issues, change the mapping type to Constant
  8. Click on Add and configure the following:

  9. This completes the validation Flow. When the Entity is added or edited, the validation Flow will execute and perform a lookup for the applicant and produce a Fatal Warning if the applicant is not found.

Was this article helpful?