Validate Data

<< Click to Display Table of Contents >>

Navigation:  Low-code Process Automation > Studio Cloud - Authoring environment > Bizagi Studio > Process wizard > Business Rules > Business Rules examples > Math operations, strings and data validations >

Validate Data

Overview

Bizagi provides functions to validate in an Expression if a specified object (a variable or an XPath) has value, is empty or is null.

 

The usage of each method varies according to the data type:

 

 

String data-type

Other data-types

CHelper.IsNull

Reviews if the object is null.

As a variable, if it has been initialized but without a value, the function returns false.

Example:

var a = "";
CHelper.IsNull(a); // Returns false
var b = null;
CHelper.IsNull(b); // Returns true

Reviews if the object does not have a value.

Example:

var a = 123;
CHelper.IsNull(a); // Returns false
var b = null;
CHelper.IsNull(b); // Returns true

CHelper.IsEmpty

Reviews if the object does not have a value.

If the variable has been initialized but empty, the function returns true.

Example:

var a = "";
CHelper.IsEmpty(a); // Returns true
var b = null;
CHelper.IsEmpty(b); // Returns true

Reviews if the parameter does not have a value. Example:

var a = true;
CHelper.IsEmpty(a); // Returns false
var b = null;
CHelper.IsEmpty(b); // Returns true

<is-empty()>

Only available for XPaths

Returns false if the string-type XPath has a value, and true otherwise (the XPath must be valid).

Example:

<Purchase.Requester.FullName> = "";
<is-empty(Purchase.Requester.FullName)>); // Returns true
<Purchase.Requester.FullName> = null;
<is-empty(Purchase.Requester.FullName)>); // Returns true

<Purchase.Requester.FullName> = "Adam Lee";

<is-empty(Purchase.Requester.FullName)>); // Returns false

if<is-null()>

Only available for XPaths

Returns true if the XPath of any type is null, and false otherwise (the XPath must be valid).

Example:
<Purchase.TotalCost> = null;
<is-empty(Purchase.TotalCost)>); // Returns true

<Purchase.TotalCost> = 10000;

<is-empty(Purchase.TotalCost)>); // Returns false

 

Considerations

Take into account the following considerations when using the available validation methods.

These functions are not intended to replace the validations performed when you define if a control in your form was set as mandatory.

We strongly recommend NOT USING logical operators such as == or =! to compare XPaths with null, for example: <idRequest.ValueToCompare>==null or <idRequest.ValueToCompare>!=null.

 

Syntax

Refer to this section to know the syntax of each method.

 

CHelper.IsEmpty

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);

 

Where Variable can be a declared variable or a valid XPath.

 

CHelper.IsNull

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);

 

Where Variable can be a declared variable or a valid XPath.

 

< is-empty()>

Returns true if the string-type XPath specified is empty or null; otherwise, the method returns false.

 

The syntax of the function is:

 

<is-empty(Variable)>;

 

Where Variable must be a valid XPath without angle brackets.

 

< is-null()>

Returns true if the XPath specified is null; otherwise, the method returns false.

 

The syntax of the function is:

 

<is-empty(Variable)>;

 

Where Variable must be a valid XPath without angle brackets.

 

Example

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 any of the available functions.

 

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

 

CHelper91

 

Define the message to be sent accordingly.

 

For CHelper.IsEmpty function:

 

CHelper100

 

//Evaluate if rejection comments were entered

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>;

}

 

For CHelper.IsNull function:

 

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>;

}

 

For <is-empty()> function:

 

CHelper101

 

//Evaluate if rejection comments were entered

if (<is-empty(PurchaseRequest.RejectionComments)>)

{

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

}

else

{

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

}

 

For <is-null()> function:

 

CHelper102

 

//Evaluate if rejection comments were entered

if (<is-null(PurchaseRequest.RejectionComments)>)

{

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

}

else

{

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

}


Last Updated 1/6/2022 4:18:40 PM