Ignore an import set value if the Target is not blank

oliver_shields
Mega Contributor

Hi,

We have 2 different sources which automatically import into the cmdb_ci_computer table. The issue is that i want one to be the primary source and not get overwritten with information from the other if it differs, but want to be able to pick and choose which values it does this for. Lets use "discovery source" as an example. If its discovered with system A, i dont want system B to come in and overwrite it.

Is there a script i can apply to the transform map to ignore a specific value from being imported (not the entire row) if the target field ISNT blank? Or is there a much better way to get this done that im missing?

Thanks

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Oliver,

So you want target field to be ignored if target value isn't blank i.e. already populated/present

use following in the transform map onBefore script

if(target.<targetField> == ''){

target.<TargetField> = source.<sourceField>

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Oliver,

So you want target field to be ignored if target value isn't blank i.e. already populated/present

use following in the transform map onBefore script

if(target.<targetField> == ''){

target.<TargetField> = source.<sourceField>

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

If you are using cmdbtransformutil in onbefore script, will it work still?

Community Alums
Not applicable
Hi Oliver, In the transform don't map the field. Then write an onbefore script, which first checks the target.fieldname and if it's blank, then you're otherwise don't update that field. Let me know in case of any issue