Copy condition

Hi

We are using a transformer to do value transformation, and for the input variable we have a copy condition specified. We want the mapping to be executed if a varibale say ‘a’ exist, if not it should use the hardcoded value.

Please let me know how to check if the variable exist in the pipeline and how to use it as a copy condition.

Regards,
Murali

Determine which value to pass before calling the transformer. I don’t think you’ll be able to do what you’re after via copy condition.

Existence of variables in conditions is checked by just entering the variable name inside two %, so the existence of var is checked by %var%, the nonexistence by !%var%.
See Deveopers Users Guide Appendix D. Conditional Expressions - Checking for Variable Existence.

Afaik it is not possible to set a copy condition for a constant. But if you map you default value to a pipeline value in a step before you call the transformer, say defaultvar, and the varavle you want to check is a, the copy condition to check the existence is just %a%.

So draw a mapping from a to you transformer and enter the copy condition %a% and a mapping from defaultvar and set it’s copy condition to !%a%

Guys,

Is anybody able to give an example for this one.

Thanks,
Sreenivas

I would recommend against using copy conditions for this. I’m not a fan of using copy conditions in general. They make reading and maintaining the code harder for no real benefit. The approach mwroblinski describes most definitely works but one should consider the readability and maintainability aspects of the approach.

Map the variable eg: “a” to “c”. now click on the map and give the condition statement in the Copy condition in property window. eg : %a%!=null . Now in the pipe line hardcode the value using “SetValue” to “c” with a constant .

If you wish not to use a copy condition then you could give this simple overwrite method a try.

1. Initialize a variable ‘var1’ hardcoded with whatever default you need.
2. Map variable ‘a’ to ‘var1’
3. Map ‘var1’ input of the transformer.

Since the variable ‘a’ is not in the pipeline the step 2 map will not happen.

Remember this would work only if you are sure you want to check for the existence of variable ‘a’ not if ‘a’ carries a null. Existence and Null value are different.

Again the readability and maintainability aspects of this approach is something you need to consider and decide.