Conditional Mappings
Overview
Conditional mappings execute a mapping only when a specific condition is true. The DataMapper supports two types:
if— Execute a mapping only when a condition is metchoose-when-otherwise— Branch across multiple conditions and execute the first matching branch, like a switch-case statement
For iterating over collections, see Loop Mappings.
If Mapping
Use if to wrap a target field: the entire field element is included in the output only when the condition is true.
Steps
Click the
⋮menu on the target field and select “Wrap with Instruction” → “Wrap with if”Select wrap with if Configure the condition — Drag source fields or type manually
Define the if condition Create the mapping for when the condition is true
Configure the conditional mapping
You can drag source fields into the condition input to quickly build expressions like $sourceField > 100 or $status = 'active'.
Conditional value with Inner “if”
Use Inner “if” when the target field is always emitted but its value should depend on a condition. The field element appears in the output regardless; only the content written into it is gated.
When to use Inner “if” instead of Wrap with “if”:
| Scenario | Use |
|---|---|
| Omit the field entirely when the condition is false | Wrap with “if” |
| Always emit the field, but write its value conditionally | Inner “if” |
Steps
- Click the
⋮menu on the target field and select “Inner Instruction” → “Inner if”
Set the condition on the
ifnode that appears inside the field rowMap the value onto the
ifnode’s child — this is the value written when the condition is true
You can add a second Inner “if” on the same field to create an alternative branch: click the ⋮ menu on the existing if node and again select “Inner Instruction” → “Inner if”. The two if nodes become siblings inside the field, each writing its value when its own condition is true.
Choose-When-Otherwise Mapping
Create branching logic with multiple conditions, similar to switch-case statements. Use choose-when-otherwise to wrap a target field: the field is emitted only through the branch whose condition matches.
Steps
Click the
⋮menu and select “Wrap with Instruction” → “Wrap with choose-when-otherwise”Select choose-when-otherwise Map the
whenandotherwisebranches — set a condition on thewhennode, then add mappings for both branches. Theotherwisebranch runs automatically when nowhencondition matches.Configure when and otherwise mappings Add more when branches (optional) — Click the
⋮menu on thechoosenode and select “Add when” to create additionalwhenbranches. Each branch can have its own condition and mappings.Add another when branch
The otherwise branch executes when none of the when conditions are satisfied, providing a default fallback.
Conditional value with Inner “choose-when-otherwise”
Use Inner “choose-when-otherwise” when the target field is always emitted but its value should come from one of several branches. The field element is always present in the output; the choose structure determines which value expression is used.
If the target field already has a value mapping (a value-of or dragged source field), the DataMapper automatically moves the existing mapping into the when branch and clones it into the otherwise branch when you apply Inner “choose-when-otherwise”. You can then adjust each branch independently.
Steps
- Click the
⋮menu on the target field and select “Inner Instruction” → “Inner choose-when-otherwise”
Set the
whencondition — click the condition input on thewhennode and drag a source field or type an XPath expressionMap the value for
when— drag a source field (or enter an XPath expression) onto thewhennode’s child rowMap the value for
otherwise— drag a source field or expression onto theotherwisenode’s child row
- Add more when branches (optional) — click the
⋮menu on thechoosenode and select “Add when”
Next Steps
Now that you understand conditional mappings:
- Loop Mappings — iterate over collections with for-each and for-each-group
- XPath Editor — build complex expressions with functions