Defining Conditional mapping by data mapping

This page teaches you how to use data mapping to define conditional mapping.

About this task

Conditional mapping applies certain data mappings under the corresponding condition. The basic structure is like [Condition][Data mapping],[Condition][Data mapping]. Users need to define the Conditions and the corresponding data mappings as a set of Conditional mapping. Defining the corresponding data mapping is like defining traditional data mapping. As for defining the Condition, there are two ways: by data mapping (Mapping editor) and by mapping flow. For the other way, please refer to Defining Conditional mapping by mapping flow.

Procedure

  1. Launch the Mapping editor and select Condition as Mapping Source. For detailed steps, please refer to Defining data formatter.

To define conditional mapping, you need to define the Condition first. Select the Condition type and define the Condition expression.

  1. Select the Conditional type as mapIf.
    Note: There are three kinds of Conditional mapping, mapIf, mapElseIf and mapElse, which stands for the processing sequence. As Conditions are nested as a group and there could be multiple Condition groups with multiple nested Conditions, users should make sure every Condition group is valid:
    • start with one mapIf and it should be the only one;
    • if needed, have multiple mapElseIf;
    • if needed, end with only one mapElse.
    In this way, every Condition must have a mapIf. And particularly, there could be many mapIfas many Condition groups are in one formatter. For reference, please see Example.
  2. Select Condition type and define the entire Condition expression according to the selected type. There are three Condition types, Expression, Global function, and Common .
    Note: The list of possible Global functions and Common s would be restricted to the target environment, such as the server-side, client-side or both.
    • Expression: logical or relational operation defined by users.
      Steps:
      1. Select one of the operators to define Expression type.
      2. Define left and right input elements according to Expression type. Click the 'browse' button on the right. In the pop-up Expression editor, select one of the supported elements and assign the value.
    • Global function: common data manipulation, such as compare and concatenate provided by BTT.
      Steps:
      1. Expand the functions tree to select the Global function. You could use the search bar to find the Global function you want and use Description label to know better about the function. Please refer to Global Functions for detailed information about the function.
      2. Define each parameter. Click the 'browse' button on the right. In the pop-up Expression editor, select one of the supported elements and assign the value.
    • Common : common condition which has been defined by users in Condition Dictionary.
      Steps:
      1. Select the Common from the List panel.
      2. Define each parameter. Click the 'browse' button on the right. In the pop-up Expression editor, select one of the supported elements and assign the value.
  3. Click 'Create' button in the Control area.
  4. After defined the Condition, you should define the data mapping applied under this condition. To define simple data mapping, please refer to Defining traditional data mapping in data formatter.
    Note: When the focus is on the Condition or inside mappings, the new created mapping will be under this condition. Otherwise when the focus is lost, the new created mapping will be outside this condition.

Under a Condition, you could define nested Conditions. You need to follow the restrictions on valid Condition group.

  1. If needed, define mapElseIf or mapElse Condition as the previous steps. After the creation of MapIf, the 'Add Nest' button is valid. This means you could define a Condition under some upper level by clicking this button at the last step.
    Note: If you created a Condition at the wrong level, you could use drag & drop to reorder the levels. For more information, please refer to Reordering the mappings.

Results

In this way, users could define multiple switches that specific data mappings would be applied under specific Condition.

Example