Validate Data

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules examples >

Validate Data

Validate if an attribute or variable is empty

In a Purchase Request process if a request is rejected, a notification is sent to the requester. The message included in the notification depends on the rejection comments. If no rejection comments were entered, it means the request was approved. Otherwise the request was rejected and the rejection comments are included in the message.

 

To validate if rejection comments were entered you can use the CHelper.IsEmpty function. This function returns true if the object specified as parameter (Variable) is empty; otherwise, the method returns false.

 

The syntax of the function is:

CHelper.IsEmpty(Variable) ;

 

 

Create an expression as an on exit action of the Authorize Request activity.

 

CHelper91

 

 

Use the CHelper.IsEmpty function to evaluate if rejection comments were entered. Define the message to be sent accordingly.

 

 

if CHelper.IsEmpty(<PurchaseRequest.RejectionComments>)

{

<PurchaseRequest.Message>="Your request has been approved"

}

else

{

<PurchaseRequest.Message>="Your request has been rejected. The reasons are:" + <PurchaseRequest.RejectionComments>;

}

 

 

 

Validate if an attribute or variable is null (CHelper.IsNull)

In a Purchase Request process if a request is rejected, a notification is sent to the requester. The message included in the notification depends on the rejection comments. If no rejection comments were entered, it means the request was approved. Otherwise the request was rejected and the rejection comments are included in the message.

 

To validate if rejection comments were entered you can use the CHelper.IsNull function. This function returns true if the object specified as parameter (Variable) is null; otherwise, the method returns false.

 

The syntax of the function is:

 

CHelper.IsNull(Variable) ;

 

Create an expression as an on exit action of the Authorize purchase activity.

 

CHelper91

 

Use the CHelper.IsNull function to evaluate if rejection comments were entered. Define the message to be sent accordingly.

 

CHelper81

 

//Evaluate if rejection comments were entered

if CHelper.IsNull(<PurchaseRequest.RejectionComments>)

{

<PurchaseRequest.Message>="Your request has been approved"

}

else

{

<PurchaseRequest.Message>="Your request has been rejected. The reasons are:" + <PurchaseRequest.RejectionComments>;

}

 

note_pin

DO NOT USE the following statements: <idRequest.ValueToCompare>==null or <idRequest.ValueToCompare>!=null

You can also use the BAIsBlank function: BAIsBlank(<Request.ValueToCompare>)