While loading data using import set , records are not inserting properly.

Abhilasha G T
Tera Contributor

Hi Team,

 

we are loading a data to  a  a field  name is OWNER  it is a choice field in the ServiceNow target table, having choices of Vanco and Customer.

from data source excel we have a field like Owner it is having a  integer value like 0 and 1 . 

we are mapping Owner fields from excel (data source) to the OWNER field in ServiceNow.

 

 

written one onBefore transform script like below,  considering '0' as a Vanco and '1 'considering as a Customer.

 var OWNER = source.u_owner.toString();

    if (OWNER == '0') {
        return target.u_choice_u_owner = 'Vanco';
    } else if (OWNER == '1') {
        return target.u_choice_u_owner = 'Customer';
    } else {
        return target.u_choice_u_owner = '';

    }

 

But this script is not working as expected, values are inserting as integer only like below, not as a Vanco or Customer.

AbhilashaGT_0-1715603216342.png

 please guide me to correct this, or how to trouble shoot this?

 

 

Regards,

Abhilasha G T

 

1 ACCEPTED SOLUTION

Vengadesh
Tera Guru

Hi @Abhilasha G T,

 

What you are trying to do is correct, try the same script in the field mapping script.(Within the field mapping , there is a field called "use source script" enable it as true and add the above script)

Else if you want to go with on before script means , rephrase your script as below:

if (source.u_owner=="0"){
target.u_choice_u_owner="Vanco";
else{
target.u_choice_u_owner="Customer";
}

Its better to utilize field mapping script for this kind of scenario 

Try this solution, if this works for you, mark mine as accepted  

 

Regards

Vengadesh

View solution in original post

1 REPLY 1

Vengadesh
Tera Guru

Hi @Abhilasha G T,

 

What you are trying to do is correct, try the same script in the field mapping script.(Within the field mapping , there is a field called "use source script" enable it as true and add the above script)

Else if you want to go with on before script means , rephrase your script as below:

if (source.u_owner=="0"){
target.u_choice_u_owner="Vanco";
else{
target.u_choice_u_owner="Customer";
}

Its better to utilize field mapping script for this kind of scenario 

Try this solution, if this works for you, mark mine as accepted  

 

Regards

Vengadesh