Transform map to avoid insert

gokul arumugam
Kilo Contributor

HI All,

I am trying to update value in location table based upon address, city, state, zip. In a transform map i make all 4 field coalesce = true. I want to update my record if my coalesce conditional match or else it should not record any new record in location table.

FYI: coalesce 4 fields are not reference filed, so i can't find Choice action to reject it

Below code will work, If coalesce condition fail in my case

if (action == 'insert') ignore = true;

Thanks,

Gokul

9 REPLIES 9

arielgritti
Mega Sage

Hi Gokul

Yes, it's works.

Take a look to this:

find_real_file.png

At this doc: https://docs.servicenow.com/bundle/london-platform-administration/page/script/server-scripting/refer...

 

Please, mark correct, useful or bookmark if I helped you

Thanks

Ariel

Harsh Vardhan
Giga Patron

write onBefore() transform map script here and mention the action condition which you have pointed in your question. 

 

Note:

To only update records where a match is found, and skip records where a match is not found, specify a coalesce field and add the following script as an OnBefore script to the transform map.

 

if (action == 'insert')

ignore = true;

 

 

if you will have multiple coalesce then it means it will treated as AND operator all the 4 values must be matched else insert will get happen on the target table. 

 

Yes, i have multiple coalesce, how to avoid a insert if coalesce match failed .?

you don't want insert for any scenario ?  generally we set coalesce to avoid duplicate record entry on target table. 

 

MULTIPLE FIELD COALESCE

If multiple fields are set to coalesce, all coalesce values are used to match an existing record. If two fields are set for coalescing and a matching value is found on one of the coalescing fields but not on the other, a new record is inserted.

The important detail about this type of coalesce is that all coalesce fields must match in order to update a record.