Exercise 4
1. Functions
Open the Xml Destination Process created in Exercise Three. The aim of this is to learn to use functions and variables. We are going to multiply the number of units by 4 if the Product Name is “LEG”.
Click on the Mappings tab. Select the Units data element.
In the ‘Map Using’ section, select “Functions”. You will see that because the “Data Element” was previously selected, it shows the “Data Element” function in the function list.
Delete the “Data Element” function by clicking the Delete link.
Click on the Variables tab.
Type in a new Variable and click Add, we will call it “Multiplier”. Add a description if you wish.
Return to the Mappings tab. Add a new Conditional function to the Units element, which puts the result into the Multiplier variable.
Our logic will be, if the Product Name is LEG, then we will set the Multiplier to 4, otherwise we will set it to 1.
Once you have added the Function, click the Edit Parameters button.
Setup the parameters as shown in the image below.
For string one, Select the data type to be DataElement and then click ProductName under the Line heading.
For String2 Select the DataType Literal and set the Source Literal to 'LEG'.
Then, do similar for ResultIfTrue = '4' and ResultIfFalse = '1'.
Click Back, add the Multiply function.
Click Edit Parameters, setup the parameters so that the Units are multiplied by the multiplier variable (Select Variable for the data Type when entering on DecimalMultiplier).
Use “G” (General) as the format.
Click OK.2.Test
Test with the CSV file as in the previous examples, the destination message is shown below.