Need to ignore all rows, if one row has error, during excel upload

sri vyshnavi
Tera Expert

Hi

Need to reject whole excel upload if one record has error.

How can I achieve it through transform map

2 REPLIES 2

SinghBalwant
Kilo Guru


There are two ways to reject or skip a transform map if any error is reported while transforming data in ServiceNow:

  1. Using the Choice Action

The Choice Action allows you to specify what should happen when an error is encountered during the transform process. You can choose to reject the record, skip the record, or continue processing the record.

To use the Choice Action, open the field map and select the Choice Action drop-down list. Then, select the desired action from the list.

  • Reject - The record will be rejected and will not be processed any further.
  • Skip - The record will be skipped and will not be processed.
  • Continue - The record will be processed even if an error is encountered.
  1. Using the onBefore Transform Script

The onBefore Transform Script allows you to execute custom code before the transform process begins. This code can be used to check for errors in the data and to prevent the transform process from continuing if an error is found.

 

Please let me know if my feedback was helpful and resolved your issue. If it was, please click the "Helpful" button below.

I appreciate your feedback! It helps me to improve my responses and better serve you in the future.

Riya Verma
Kilo Sage
Kilo Sage

Hi @sri vyshnavi ,

 

Hope you are doing great.

use an onStart() transform script that runs a glide query against your import table, filtering for your failure condition and the current import-set, if a result is found abort the transform.
use code something below like this :

var dataCheck = new GlideRecord('yourTransformTable');
dataCheck.addQuery('yourField', 'yourValue');
dataCheck.addQuery('sys_import_set', source.sys_import_set);
dataCheck.setlimit(1);
dataCheck.query();

if(dataCheck.next()) {
//at least 1 record meets validation failure condition so abort the import;
ignore = true;

}

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma