Skipping Field Map on Data Transform

TramaineM
Kilo Sage

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);

 

 

 

 

 

 

4 REPLIES 4

ersureshbe
Giga Sage
Giga Sage

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;

}

Regards,
Suresh.

Hi @ersureshbe ,

 

Same issue as it populates the last name to undefined. 

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.

Regards,
Suresh.

I'm doing this on the first_name and last_name fields which are both string.