(b2b Integrator Version 4.0.2) I’m mapping one string value from the Pipeline-In to a string value in the “From Item” record of the AppendToRecordList service and simultaneously defaulting a string value in the “From Item” record as well. Ideally I would like to only map the value from the Pipeline-In and default the string value if the Pipeline-In variable is not $null.
There are two things
- Defaulting a value
- Conditional Mapping
Create a MAP operation and assign a value to string variable. Uncheck ‘Override pipeline value’
. This will default a value to the variable.
For conditiona mapping (i.e. ‘Copy only if’ ) have a variable that holds value for condition, lets say a variable ‘con_var’ that holds value ‘1’. On map specify condition (‘Copy only if’) “%con_var% > 1”
Use a Branch construct, using the variable as the character you branch on. Use 2 Sequence constructs under the branch with $null as the first label, $default as the second. Code the map accordingly.
BRANCH on ‘/variable’
Looks like you have a solution that works, but here’s another angle. I think the problem is that you’re trying to do the default setting and the condition map copy at the same time, and the default setting is always “winning”.
Try doing a MAP of the default value to “fromItem” first. And then do the conditional copy in the INVOKE. Some of the expressions you list may work. Another would just be:
variable != $null
As this thread points out, there are several ways to do it, but here is what I think is most elegant:
You have an invoke of AppendToStringList (I assume it is string, not record list).
- Draw your map line from your variable to the fromItem.
- set the Copy-only-if to be ONLY the variable name example: %myVariableName% (this will copy only if the variable exists), and I doubt it is even really necessary–but it needs to be conditional to allow you to also do a set-input on the fromItem.
- set-input to the default value on fromItem(i.e. ‘UNKOWN’ or whatever you want it to be). UNCHECK ‘Overwrite pipeline value’.
Voila, you’ve set the default and mapped all in one line.