In import log error message , is it possible to display the row number of the excel where value is invalid along with the error ?

Servicenow12
Tera Contributor

In import log error message , is it possible to display the row number  of the excel where value is invalid along with the error ?

I am using Use source script to throw an error if the value is invalid as below, Can we bring the row number also where the error is found ?

 

answer = (function transformEntry(source) {

 var user= source.u_assigned_to;

 var gr = new GlideRecord("sys_user");
 gr.addQuery("name", user);
gr.addQuery("active",true);
 gr.query();

 if (gr.next()) {
    return gr.name;
 } 
 else{
    log.error('There is no user available with name   ' + source.u_assigned_to);
 }

1 ACCEPTED SOLUTION

you can use source.sys_import_row to display the current row in error_message like this

if(source.name=="no_tranform"){
  error = true;
  error_message = "Source is not intended for transformation" + source.sys_import_row ;
}

View solution in original post

6 REPLIES 6

MrMuhammad
Giga Sage

Hi - I'm not sure if there is a import_set_row object is available to access the row number but if you navigate to sys_import_set_row_list.do then you will be able to see row column that you can query and leverage for your purpose.

Regards,

Muhammad

Regards,
Muhammad

Vipul Sethi
Kilo Guru

yes its possible, you can use transform script variable error and error_message given below, which can display the error message in error field of import set row records  :

if(source.name=="no_tranform"){
  error = true;
  error_message = "Source is not intended for transformation";
}

I have to display the row number from Excel in my error 

you can use source.sys_import_row to display the current row in error_message like this

if(source.name=="no_tranform"){
  error = true;
  error_message = "Source is not intended for transformation" + source.sys_import_row ;
}