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 10:36 AM
Hi,
Can you try the below code
answer = (function transformEntry(source) {
var sourceName = source.u_last_name;
var targetName = target.user_name;
if (JSUtil.nil(targetName ){
if(JSUtil.notNil(sourceName )){
return sourceName ; // return the value to be put into the target field if name1 is not empty
}
}
})(source);
Thank you ,
Srikanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 11:06 AM
Unfortunately, same undefined issue as above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2023 06:22 AM
Any thoughts on why this is populating with "undefined"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2025 01:02 PM
To ignore that field updation, write return null; if the condition fails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2024 02:22 AM
Firstly you want to set a value and not to compare it so ignore = true is a correct statement and secondly as I was dealing with a similar issue, I've discovered that you can ignore the row only in the transform map itself in the main script or in a transform scripts...