Adding conditions to a map

Use conditions to dynamically manage field links based on data values or processing logic.

Before you begin

  • Log in to your tenant.
  • Create the flow service as described in the About this task section.

About this task

Create a flow service named CentimetertoMeterConversion, which converts input values from centimeters to meters. If the result is zero meters, a custom message is logged.

The flow service includes.
Service. Math.multiplyFloats
Runs a multiplication operation between two floating-point numbers.
Service Input
num1. Receives the input value from the pipeline. For example, centimeters.

num2. A constant conversion factor set to 0.01 (used to convert centimeters to meters).

Service Output
Value. The result of multiplying num1 by num2, representing the converted value in meters.
Pipeline Input
centimeters. The original value to be converted.

minValue. A threshold value used to determine whether conversion proceeds.

maxValue. A limit used in conditional logic.

default. A fallback value is used when minValue is a certain threshold.

Pipeline Output
meters. The final converted value in metersis, which is derived from the service output.
Conditional Step
If the meters value is equal to zero, a custom message is logged to indicate that the conversion result is zero. Modify the logic of the flow service such that it converts only specific values instead of all values based on the conditions.
  • num1 = minValue > 1 and maxValue < 9999
  • default = minValue < 1

Procedure

  1. Go to the CentimetertoMeterConversion flow service.
  2. Select the centimeters to num1 map and click Pipeline Condition from the pipeline toolbar. The Condition Editor page appears.

    By default, the first field is selected and displayed in the editor.

  3. Make sure that the Enable Condition during execution checkbox is selected. Otherwise, the condition is not considered at run time.
  4. Define the conditions. For more information on how to define conditions and sub conditions, see Creating Complex Expressions.

    The condition minValue > 1 and maxValue < 9999 is defined for the selected mapping.

  5. Click Save. The condition is saved, and the Map by Condition icon appears to show that a condition has been applied to the map.
  6. Map the default pipeline Input field to num1.
  7. Define the condition for the Default pipeline Input field.
    Note: To remove a condition from a map -
    • Select the map and click the Map By Condition icon. The Condition Editor appears.
    • Click Remove Condition.
    • Click Run. The results are displayed based on the values that you provide.