Maximum value using expressions

<< Click to Display Table of Contents >>

Navigation:  Low-code Process Automation > Studio Cloud - Authoring environment > Bizagi Studio > Process wizard > Business Rules > Business Rules examples > Cases and activities > Managing user interface >

Maximum value using expressions

The following example illustrates how to set a maximum value for a control.

 

Suppose a Transportation and Logistics company has defined a process called Shipping Process, to manage and monitor international shipments. The first task of this Process allows the customers to enter the information and estimate the cost of the shipment.

The company provides shipping services between Brazil, Ireland and United States. Transportation of goods can be by air, land, or sea. If the selected means of transport is air, an express service is offered for same-day shipping and delivery.

 

The data capture form to collect this specific information is as follows:

 

ManagingUserInterface

 

The maximum dimensions a package can have varies according to the transportation means selected. The following table shows the maximum permissible height for each mode of transport. Use and expression to validate the condition.

 

Transportation Means

Maximum Height Allowed (ft)

Air

70

Maritime

94

Land

100

 

1. Select the Height control in the Form to display its Properties.

 

ManagingUserInterface30

 

2. Locate the Maximum behavior in the Advanced properties tab. Click the Expression icon.

 

ManagingUserInterface31

 

Click New to create a new expression.

 

ManagingUserInterface51

 

3. In the new window add an expression module.

 

ManagingUserInterface32

 

4. This expression calls for certain Constant definitions to be previously defined in the vocabulary, by which to reference specified entities values.

These definitions will contain the internal identifier, which is an attribute of the entity, of the transportation means.

 

ManagingUserInterface50

 

5.Type the following code and save the expression:

 

ManagingUserInterface33

 

//Declare the variable to return

var MaxValue = 0;

 

//Obtain code of air transportation from vocabulary

var AirCode=CHelper.resolveVocabulary(Me,"Air");

 

//Obtain code of maritime transportation from vocabulary

var MaritimeCode=CHelper.resolveVocabulary(Me,"Maritime");

 

//Obtain code of land transportation from vocabulary

var LandCode=CHelper.resolveVocabulary(Me,"Land");

 

 

if (<Shipping.TransportationMean.Code>==AirCode)

{

MaxValue = 70;

}

if (<Shipping.TransportationMean.Code>==MaritimeCode)

{

MaxValue = 94;

}

if (<Shipping.TransportationMean.Code>==LandCode)

{

MaxValue = 100;

}

 

//Return the result

MaxValue;

 

6. Test the expression in the Work Portal. Bizagi will display a message if a value greater than the permissible height for the selected Transportation Means is entered. This validation message will be thrown once you click the Next button.

 

ManagingUserInterface34

 

note_pin

Keep in mind that the type of value returned in the expression must coincide with the type of value that the control manages (e.g dates with dates, integer with integer). If they are different, errors may occur in the execution of the form.

 


Last Updated 1/25/2023 4:58:11 PM