All product information in wiki.bizagi.com is only valid for Bizagi BPM Suite 9.1.X.
For newer Bizagi BPM Suite versions (10.X and up) please visit the User Guide.
 

How to create Grid Validations with rules

From Business Process Management, BPM and Workflow Automation Wiki | BizAgi BPMS

Jump to: navigation, search

<keywords content="keywords">

create grid validation, rules, grid validations

</keywords>

Contents

How to Create Grid Validations with Rules

Tables always consider a 1:N (one-to-many) relationship  between two entities. Using validations on tables with rules, allows the user to validate conditions within the N entity, in order to save or edit a record.

That is, when clicking the SAVE button, when Editing or Adding a record, the rule is executed, presenting error messages by the Bizagi assistant.


Always keep in mind that these validations are built in the context of the N entity.


In this example, a Credit Request Process must validate that the requested value of all the products are within a given range.Thus, the context of the expession will be the N entity, Products.

This range is parametric and has been included in the ProductType entity as shown below



1. Open the Forms Designer where the Table has been created.

Locate the Grid option in the Properties box



2. Click on the Edit or Add Form Validation to select an Expression rule.

A new window will open. If the rule has already been created, select it and click OK

If the rule has not been created, click on NEW


3. Create the rule

Click for further information about Expressions





3. Select the rule



4. The error message will be shown when Adding or Editing a new register of the grid



Using Xpath to avoid duplicates

If you need to make sure that all records in a collection are unique you can validate a new record being created using an XPath expression.

Suppose you have a process called ProcessA  The business process entity is called EntityA and it has a one-to-many relationship  with EntityB. The relationship is called CollectionB. Additionally EntityB has a one-to-one relationship with a parameter or master EntityC. You wish to validate that all records in the collection of the EntityB have no more than one record of each value of EntityC.

Then, when the user is creating a new record of the collection in the Work Portal, there must be a validation when the condition is not met. To do that you must define and expression in the Edit and/or Add Form Validation property in the Forms editor (For more information about form properties see Form Properties ). The expression has the following structure:


//Get Value being entered

var TargetValue = Me.Context.getXPath("EntityC.id") 

//Validate duplicates

if (Me.getXPath("exists(EntityA.CollectionB[EntityC ="+ TargetValue +"])") ==true) 
{ 
//Validation Message

CHelper.ThrowValidationError("Error message") 

}


For exmaple: In a CRM (Customer Relationship Management) process you may have two different entities, one for all the Customers and one specially for VIP Customers. In this case EntityA is CRM, EntityB is the list of VIP Customers and EntityC is the list of Customers. It is not desirable to enter a Customer in the list of VIP Customer twice.

The expression would be as follow:


//Get Value being entered

var TargetValue = Me.Context.getXPath("Customer.id") 

//Validate duplicates

if (Me.getXPath("exists(CRM.VIPCustomers[Customer ="+ TargetValue +"])")==true)
{
//Validation Message 

CHelper.ThrowValidationError("This Customer already exists in the VIP Customers list")

}


If you try to enter a Customer twice in the list of VIP Customer a validation message will be displayed.


Related Information

<comments />