Conditionally update only one field map in a Transform map

Jonathan_Batist
Kilo Contributor

I have a Transform map with multiple field maps, but want to perform an update on only one field map and ignore the rest depending on a certain field's value in the target table.

For example, in my test user table, if the u_test field is empty then only the phone field should be updated. But if the u_test field has a value, then the whole record should be updated as normal.

if(target.u_test == ''){
  target.phone = source.u_phone;
  ignore = true;
}

I tried this in an onBefore script, so the value would get set and then hoped it would ignore the rest of the field maps for the record, but it still just ignored the whole record and did not update.

 

1 ACCEPTED SOLUTION

Tony Cattoi
Mega Guru

Setting ignore = true is going to skip the line for the update in the on before.  For a simple solution, you could always just add a second transform map for your import where the phone is updated for items that have a value in the u_test field (or just let it run for everything if it doesn't matter if the phone gets compared a 2nd time as it should ignore it).

View solution in original post

2 REPLIES 2

Tony Cattoi
Mega Guru

Setting ignore = true is going to skip the line for the update in the on before.  For a simple solution, you could always just add a second transform map for your import where the phone is updated for items that have a value in the u_test field (or just let it run for everything if it doesn't matter if the phone gets compared a 2nd time as it should ignore it).

Jim Coyne
Kilo Patron

Instead of having the individual field maps then, you could script it out similar to this:

find_real_file.png

 

BUT, you'll want to have at least one field map with the Coalesce check box selected so the transform map knows what to match on.