Welcome to the new Data Mapper Patterns series where we will walk you through some quick scenarios that help you take advantage of the capabilities found in the new Data Mapper Preview. Note: As of this writing the Data Mapper is currently in Public Preview.
The scenario that we are going to explore in this post is conditional mapping. There are built-in functions that can help us achieve our desired outcome. To demonstrate these capabilities, we will walk through two scenarios:
1. If Condition
In this example, we want to apply the following business rule:
If Plant (source) == "71000"
Then Plant (destination) = "71000-A"
We can achieve this by adding an Equal function to our canvas and then checking to see if PLANT is equal to "71000". The output of this function will be a boolean value. We can then pass this boolean value into our If function as our first parameter. The second parameter the If function takes will be the value that we want to pass to our destination. In our case, we will hardcode "71000-A". If you want to include a value from the source you can also do that.
Equals function followed by If
2. If Else Condition
This example is similar to the example above, but we can now account for an else condition. The business rule that we want to implement is the following:
For this scenario, we will first use the Equal function to check to see if STCK_TYPE is equal to "F". This function will output a boolean value which we can pass to the If else function. We now need to provide two additional parameters to the If else function. When our Equal function evaluates to true, what value should we pass to the destination? In our case we will pass "F-0". Similarly, we need to provide a value when our Equal function provides a false output. In this case, we will just map our original STCK_TYPE across to our destination.
Equals function followed by If Else
If you would like to see this content in more details, please check out the following YouTube video:
What scenarios would you like to be covered in this series? Please add a comment below.