Ignore Field Map Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 07:27 AM
Hi, I'm trying to create a field map in our internal database employee import that will skip updating the first and last name fields if the user contains a user_name in ServiceNow. The reason for this is not all users will have a user_name or email address, but the ones who do, will have the first & last names updated from Azure if it changes.
Here is the source script I have for the last_name field on the sys_user table that is still updating the field regardless of user_name:
answer = (function transformEntry(source) {
var name1 = source.u_last_name;
if (target.user_name.nil)
return name1; // return the value to be put into the target field
else
ignore == true;
})(source);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 07:38 AM
hi Tramaine,
Can you try below
answer = (function transformEntry(source) {
var name1 = source.u_last_name;
if (target.user_name==''){
return name1; // return the value to be put into the target field
}
else{
//do nothing
}
})(source);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 08:08 AM
Hi Jaspal,
Thanks for the response. This is similar to a previous script I tried. I just tried it and it changes the last names to "undefined", ex. John undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 08:53 AM
Hi @TramaineM ,
Can you try below script :
answer = (function transformEntry(source) {
var name1 = source.u_last_name;
if (target.user_name==''){
if(name1!=''){
return name1; // return the value to be put into the target field if name1 is not empty
}
}
})(source);
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 09:49 AM
Hi @Gunjan Kiratkar,
Same issue as above. It's changing the last name of all users with a user_name to undefined.