<< Click to Display Table of Contents >> 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 = ""; |
Reviews if the object does not have a value. Example: var a = 123; |
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 = ""; |
Reviews if the parameter does not have a value. Example: var a = 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> = ""; <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> = 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.
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.
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.
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.
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.
Define the message to be sent accordingly.
•For CHelper.IsEmpty function:
//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:
//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:
//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:
//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