Default value using expressions

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules examples > Managing user interface >

Default value using expressions

When the default value option is used for controls that are relating a table, such as combos or lists, they receive the identifier of the record that wants to be displayed. That is, the expression used must return an integer. Make sure the identifier is actually found in the related table.

 

The following example illustrate how to set a default value for a control.

 

Example

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 shipments.

The company provides shipping services between Brazil, Ireland and United States. Transportation of goods can be by air, land, or sea. If the transport mean selected is air, the express service is offered in order to deliver packages the same day they are sent.

 

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

 

ManagingUserInterface

 

 

The company requires initially the country of origin to be that of the person entering the shipping information. Later, the customer may choose the shipment to originate from a different country. An expression is needed to identify the user's country of residence and assign this value to the country of origin. Bear in mind, for this expression to work correctly, that Country must be allocated as a user property for all users.

 

1. Select the Origin Country control to display its Properties in the panel on the left.

 

 

ManagingUserInterface43

 

 

2. Locate the Default value behavior in the Advanced properties tab. Click the expression icon to display the Expression editor.

 

ManagingUserInterface44

 

 

Select New to create a new expression.

 

ManagingUserInterface51

 

3. Add an expression module.

 

ManagingUserInterface46

 

4. Enter the following sentence and save the expression:

 

ManagingUserInterface47

 

 

//Returns the ID of the country specified in the user properties of the current user.

Me.Case.WorkingCredential.UserProperties["idCountry"];

 

note_pin

The user property name (in this example idCountry) corresponds to name of such attribute within the WFUSER Entity. In order to find this name, go to the Entities module in the Expert view.

 

ManagingUserInterface56

 

5. Test the default value in the Work Portal. Create a new case and see how the Country (From) is automatically filled.

Remember to add Country as a user property of all users.

 

Log in as a user from Brazil and create a new case. Notice the country of origin is the value held in the user property.

 

ManagingUserInterface45