Adding Validation rules to Decisions Entities

Last Updated: 12/05/2018 Introduced in Version: 2.0

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. You 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 validation options.

 

 
 
  • Validation Rule – By default set to a logical rule, this rule enforces a true/false evaluation when creating an entity. 
  • Advanced Validation Rule – By default set to data return rule, returning data of type ValidationIssue. You can get more sophisticated in your validation using this type; for example, using either Warn or Fatal error level and providing a custom error message.
  • Validation Flow – A flow is used to enforce 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:
 
 10
 
The Add Applicationinfo  screen above is what appears when the Add > Entity [User Defined] > ApplicationInfo option is selected:
 
25 
 
 
The only existing validation on the Add ApplicationInfo screen is for requiring EntityName. A simple rule will be added to enforce a minimum quote amount of $1,000. Browse to the actions folder for the entity, which in this example, is under Insurance Application Design> ApplicationInfo >  Entity Actions.
 
Click on Validation Rule > Validation Rule.
 
 
 
Name the rule and click OK.
 26
 
 
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. (However you should want to evaluate additional data and factor that into the decision-making.) In the Start Rule window, click  Add New Rule Step.
 
 4
 
Expand Entity and select Income[Data]. Click Next.
 
5 
 
Expand Number Rules and select Greater Than Or Equal To, and click Next.
 
6 
 
 
Lastly, type 1000 in the Value field and click Done.
 
7 
 
Save and close the rule.
 
Back in the portal, navigate to a folder that has the entity action for adding the entity for which the rule was established. Click the Add option for the entity.
 
 8
 
 
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.
 9
 
 

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:
10 
 
 
The Add ApplicationInfo screen above is what appears when the Add > Entity[User Defined] option is selected:
 
 11
 
 
The only existing validation on the AllApplications screen is for requiring EntityName. A simple rule will be added to enforce a minimum quote amount of $1,000. Browse to the actions folder for the entity, which in this example, is under Insurance Application Design > Application Configuration.
 
Click on Validation Rule > Advanced Validation Rule.
 
 
 
Name the rule and click OK.
 
 13
 
Notice the difference in the properties, compared to the simple type of rule:
 
14 
 
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. The output data type is ValidationIssue, which includes the following properties:
 valuesProperties
 
 
In the Start Rule window, select Add New Rule Step.
 
Expand Entity and select Income. Click Next.
 
 15
 
Expand Number Rules and select Greater Than Or Equal To, and click Next.
 
17 
 
 
Lastly, type 1000 in the Value field and click Done.
 
18 
 
Next, set the true and false data to return. In this example, we’ll simply use constant data. Under Then section Else Return, select the mapping type Constant. Click the Add New button, and enter the following:
 
19 
 
  • 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 – Can be left blank; by default, this is a System.Object. This field is relevant if there were editable properties of the object.
Leave Then > Return mapping value Null, since we do not need to take action for when the rule evaluates true.
 
20 
 
Save and close the rule.
 
Back in the portal, navigate to a folder that has the entity action for adding the entity for which the rule was established. 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.
 
 22

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:
 
 10
 

Browse to the actions folder for the entity, which in this example, is under Insurance Application Design> ApplicationInfo Configuration.

Click on Validation Rule > Validation Flow.
 
Name the rule and click OK.
 
23
The flow is automatically configured with the entity input data. Conceptually, the database lookup would resemble:
27
 
 
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. The Failed path represents the applicant does not exist in the database. Therefore it is connected to the Invalid end step. Click on the Invalid step. Notice the Output data by default is ValidationIssues.
 
Under Inputs > Validation Issues, change the mapping type to Constant. Click on Add and configure the following:
 
 28
 
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.
 
 

Additional Resources