Skipping Field Map on Data Transform
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2023 01:10 PM - edited ‎09-28-2023 01:11 PM
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);
Based on suggestions in another previous post, I tried the below script but the field populates with 'Undefined' value for all of the last names.
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
‎10-02-2023 04:05 AM
Hi, pls use like below and try it with REST API explorer using sample payload
if( target.user_name == '' && target.user_name.nil())
{
target.user_name = source.u_last_name;
}
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 12:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 11:48 PM
Hi, can you pls verify the field name. Is the string or reference type. If reference type pls modify as string and try the transaction.
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 06:32 AM
I'm doing this on the first_name and last_name fields which are both string.