how to check target fields are empty before updating with transform map

sankon
Kilo Expert

Hi,

   I have to update more than 100,000 records in sys_user table with location, phone number and email from an excel sheet. Some of the records have one or more of the values missing and some have all the values. I want to know what is the best way to check if any of the fields are empty and update the field with the value from excel sheet. I also want to skip any records that have all the values. I do not want to insert any new records. Is it better to use transform script? If so, Do I use onBefore? How do I check if any of the fields values are missing and only update the missing values? Appreciate it.

Thanks in advance!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can only determine if the target field is empty or not once you determine if record is to be created/updated based on Coalesce field

You can use onBefore transform script for this

Example for 1 field. enhance for other fields as well

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here

if(target.last_name == ''){

target.last_name = source.u_last_name;

}

})(source, map, log, target);

Regards
Ankur

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

View solution in original post

7 REPLIES 7

Hi,

Should work fine.

Did you check it went to if statement or not?

Regards
Ankur

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

I'm not familiar with the check. Please guide. Thank you.

Hi,

When i try to gs.log(target.correlation_id) in field map it return it empty even if it us not? Can field map even see target fields?