Using Copy Condition in transformers

Hi all,

I have a scenario where input field ‘A’ has to be mapped to output field 'B’only if there is some value in A, otherwise if it is coming as a null value, it should not get mapped. I have a transformation to be made for the input field. so i took a transformer in the map step and mapped ‘A’ to transformer input and transformer output to output field ‘B’ for which allow null property is false. I put a copy condition like %A%==/[^ ]/ for the input mapping link, it is working fine as long as there is some value coming in ‘A’,

If there is nothing coming in A, then B is getting populated as null and it is failing since B doesn’t accept null value.

Could someone tell me how to fix this. Am I supposed to use Branch condition instead of copy condition. Please shed some light

Thanks

I have to try your scenario. Try using a branch step with evaluate label as “true” use expression as %A%!=$null && %A%!=’’

Thanks for your response. Wouldn’t it work only with copy condition without using branch.

Hello – You just keep the same expression as part of Copy condition, it will work. You no need go for switch.

Thanks,

No, it’s not working. The value is coming as null if nothing is passed in A. Please find the attached image for better understanding.

Try this, %A%!=$null && %A%!=’’

Thanks,

No luck. still the same.

PFA snapshot.

Thanks,

This will work if it is a direct mapping. I am using a transformer in between and facing the issue.

Hi,

you will have to put the copy condition on the output mapping as well.

If this does not work, you will have to go for the branch option.

Info:
Transformers are executed when the output is mapped (not sure if this applies when using a copy condition in this).

Regards,
Holger

Are you still looking for the solution for this issue.Here are my findings.

Expression : %A%!=$null && %A%!=’’

  1. Make sure you select the transformer and change the validateInput property as true.
  2. Your logic should be in Try - Catch block.

I tried it and is working to me.