<< Click to Display Table of Contents >> 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:
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.
2. Locate the Maximum behavior in the Advanced properties tab. Click the Expression icon.
Click New to create a new expression.
3. In the new window add an expression module.
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.
5.Type the following code and save the expression:
//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.
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