Empty fields in a record

Hi all,

My issue is:
Input:

  1. a record (it could contain sub-records)
  2. a substitution symbol

Output:

  1. a record (the same structure as an input one)

Goal:
If a field of input record is not empty -> just copy it in an output record
If it is empty -> substitute it with a substitution symbol

thanks in advance,
Vassili

You can do this with a transformer. Write a flow service that takes an object as input, the transformer tests the input for null, if so, put the substitution into the output pipeline, otherwise put the input variable back to the output pipeline. Instead of direct maps, map each field through this transformer.

thanks Eric,
that’s what I was thinking about before. I was looking for a more simple solution, because if I had 50 fields in the record I would have to use 50 transformers.

I used the next method:

  1. I created a new record with the same structure as the source one
  2. I assigned ‘*’ to all the fields
  3. I mapped the source record to this new one

As the result, I have the new record with the same structure and ‘*’ for the empty fields.

Question: maybe someone can tell me if there is another way to keep the same record structure if in run-time there are empty fields.

Hello Vassili, not sure if you have found the better way. Anyhow, when set a variable value, you can untick the overwrite pipeline value box. This will subsitute the variable with your subsitude sympol if the value is empty.

Hi The Terry,

it’s quite elegant, but what should i do, if i need to implement this service like a transformer or just as a flow step?

Vassili,
Both of these methods should work

Loop over OldList
Map (OldList to NewList)
Map (Set Value to Constant with ‘Overwrite pipeline value’ unchecked)

or

Loop over OldList
Map (Initialize NewList Iteration to Constant)
Map (OldList to NewList using ‘Copy only if…’ on each mapping)

I think it comes down to a personal preference.

Hi,

Use the second method in Jesse’s posting.

Loop over OldList
Map (Initialize NewList Iteration to Constant)
Map (OldList to NewList using ‘Copy only if…’ on each mapping)

Also you need to nullify the filed values before you apply the conditional map.

Thanks,

Pauly

thanks a lot for your replies,

best regards,
Vassili