How to set a default field value in a multi-selection field

In some cases, you might want to set a default value in a multi-selection field (RadioButtonList, CheckBoxList, DropDownListBox, etc.).

Your first instinct might be to simply set a value directly in the Form Designer, but then the value selected by the user will reset to the value you set whenever a new action is launched.

Instead, set the default value either on the Mapping screen or in the .NET editor.

Example

In this example, we want to set the value of the Approval field to YES.

image


First, go to the Mapping screen and select the VALIDATES action, in which the user selects their approval decision.

Now, set an IN value for the Approval field. There are three ways to set a default value.

Method 1: Using a text value

This solution is the easiest to implement, but if you loop back to the Approval action, the default value will be used.

To use a text value, click Value IN, then set the default value (YES in this case) in the Text area.

Method 2: Using an existing data with a default value

In this method, the default value is used only once, and if you loop back you’ll get the updated decision as long as Data In and Data Out use the same data.

  1. On the Data tab, create a new data (such as APPROVAL_DECISION), and set the Default value text field to YES.

    Create%20data

  2. Return to the Mapping screen and select the Approval action.

  3. Click Value IN, then select APPROVAL_DECISION.

  4. To save the value selected by the user, set APPROVAL_DECISION to OUT.

Method 3: Using .NET code-behind

Another solution is to use the .NET editor.

Sample code

 protected void Page_Load(object sender, EventArgs e)
    {
        if(CurrentWorkflowActionName == "VALIDATES"){
           APPROVAL_DECISION.SelectedValue == "YES";
        }
    }

Note: Be careful if you loop back to the VALIDATES action, because the selected value will always reset to YES.

Result

Now, when the system launches the VALIDATES action, the Approval field’s default selected value is YES.

image

1 Like