If-Else
Description: | Add an If-Else block to branch out the data based on conditions. You can then add appropriate Transformation blocks for the True and False conditions. The If-Else Transformation differs from the other blocks as you can create two Transformations based on the condition outcome. |
Available Filters: | Event Filters: - Event Type - Event Field |
Settings: | None. |
Transformation Considerations: | - The If-Else block branches the code to apply the Transformation. You cannot currently merge the branches post-Transformation, and have to write the subsequent Transformations for each branch separately. - To delete the If-Else block, you must first delete its branches. |
Sample Transformation
Scenario: If the author
is Galos, Mike, then add a new field status
with value Discontinued. Else, rename the field, price
to discounted price
and change its value to 90% of the original value.
Filters:
- Event Type =
catalog.book
-
Event Field =
author
with value =Galos, Mike
Settings:
- True condition: Add a Field
- New Field Name =
status
- New Field Value =
Discontinued
- New Field Name =
- False condition:
- Rename Field
- Field Name =
price
- New Name =
discounted_price
- Field Name =
- Change Field Values (filter on Field Name =
discounted_price
)- New Value =
0.9*$self
(The$self
keyword is used here to indicate theprice
field.)
- New Value =
- Rename Field
Results: When you test the Transformation, the data is changed based on the condition outcome as follows:
-
If True: The
status
field is added with value as Discontinued: -
If False: The
price
field is renamed todiscounted_price
and its value is changed from 5.95 to 5.355:
Last updated on May 30, 2023