- Welcome
- Introducing Babelway B2B Integration
- Starting with Babelway
- Managing Account Environments
- Managing Channels
- The Catalogue
- Tracking Messages
- Managing Alerts
- Managing Your Account
- Best Practices
- Channels
- List of Channels
- View Change Log
- General
- Gateway In
- Message In
- Transformation
- Message Out
- Gateway Out
- Email Gateway Out
- Ftp Client Gateway Out
- SFTP Client Gateway Out
- Ftp Server Gateway Out
- AS2 Gateway
- Http Client Out Gateway
- Web Gateway
- Generic Gateway
- Internal Gateway Out
- Null Gateway
- OFTP Server Gateway out
- OFTP client Gateway out
- Http Out Gateway
- SOAP Gateway
- Soap Client Out Gateway
- X.400 Gateway out
- Aggregator Gateway Out
- Email Gateway Out
- Email Notifications
- Routing
- Testing
- List of Channels
- Building a Channel
- The Catalogue
- Tracking Messages
- Alerts
- Account Management
- Rest API
- Receive Orders From
- Receive Orders from Colruyt
- Receive Orders from Carrefour
- Receive Orders from Brico
- Receive Orders from Castorama
- Receive Orders from Cora BE
- Receive Orders from Delfood
- Receive Orders from Delhaize
- Receive Orders from DEliXL
- Receive Orders from Intergamma
- Receive Orders from Intermarche
- Receive Orders from JavaFresh
- Receive Orders from Makro
- Receive Orders from Match
- Receive Orders from Carrefour France
- Receive Orders from Colruyt
- Integrate Orders with
- Integration with Tradeshift
- Integration with Exact Online or Exact Globe
- Channel:SAP Idoc XML Order05 w/ Http client out
- System Metadata
- ODETTE Messages List
- External References
See: Managing Channels - Message Transformation Functions
If function means that for each occurrence of the loop, check the condition before generating an output.
If is more like a toggle for the mapping. The transformation evaluates the If expression, and if this expression is true, it will apply the mapping. But if it is false, the mapping will not be applied and the target element of the mapping will even not be created.
You can for example create a specific target element only if the value of a source element equals MyValue: “ .='MyValue'”
If will only create the target element if the expression is validated, but will not change the value of the mapping.
The If function is used to test a condition before doing the mapping and generating the output.
You can add a If function as an Xpath expression to any mapping rule to condition the execution of this mapping rule, that is to decide if the mapping is performed or not on the input data. Note that the If function does not always return an element, if the filtering condition is not met, the mapping is not performed and so no output is generated.
The If function will only create the target element if the expression is validated, but will not change the value of the mapping.
The If can be used on any element as illustrated in the following examples.
The If is done on the mapped element parent, that means that the filter context is the mapped element parent and not the mapped element itself as with the Filter function. This is because the condition is tested before the mapping is done (or not), so the condition must be tested against the element parent as the element may not exist.
The Filter function is applied on the mapped element and always returns a result. That is not the case for the If function that is applied before the mapping, meaning that, if the condition is not met, the mapping is not performed. See the Filter Function chapter for more details.
If example on a value node
In the following example, the node mapping is tested on the Price value and the mapping output is generated only if it is greater than 12 (Xpath filter expression is ' .>12 ').
Input csv file:
Code, Quantity, Price A23, 2, 12.5 A24, 3, 10.0 A25, 1, 15.2 A26, 2, 13.6
In the second ligne, the Price is lower than the test value and the mapping output will be empty. Note that the output is not generated and so the separating comma is not present (as opposed to Filter function output).
Output csv file:
Code, Quantity, Price A23, 2, 12.5 A24, 3 A25, 1, 15.2 A26, 2, 13.6
If example on a loop node
Doing a test on a loop node will condition the whole loop generation or not. The previous example is not very meaningful in this case. A loop is not conditionned to its own elements but can be conditionned to an external element such as a date or a general value as in the following example.
In the following example, the entire loop mapping is filtered on the Type of Invoice value and the mapping of the entire loop is performed only if this value is equal to 'AAA' (Xpath filter expression is ' csv/line[1]/field[1]='AAA' ').
The following input csv file (the same as in the previous example, but with an additional 'invoice' line) is used as input:
Code, Quantity, Price AAA, 001, 25/09/2009 A23, 2, 12.5 A25, 1, 15.2 A26, 2, 13.6
The hereover Xpath condition, as it is met by the input file, will generate the following output file, including the complete loop data:
Code, Quantity, Price A23, 2, 12.5 A25, 1, 15.2 A26, 2, 13.6
If the hereover Xpath condition is modified such as it is not met anymore by the input file, the loop data will not be generate and the output file woul simply be:
Code, Quantity, Price
Babel Academy
Community Forum
Support



Prev


Up
Reference Manual