The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Create an error file when an import is failed in transform map.

Mayuri S
Tera Contributor

Hello Team,

 

I have a requirement, wherein i am validating a field "account" ,through transform map and if that validation fails , the data from excel will not be loaded in Target Table ie Employee . Now this validation is written through Transform Map script and the data whose validation fails , is updated as false for the field "account" in "Employee " table , so for these scenarios where import is failed i want to generate an error file which will say that "3 out of 10 import is failed " and attach this file to the request generated.
Could anybody please help me with this.

2 REPLIES 2

RaghavSh
Kilo Patron

You can write the Oncomplete transform script like below:

 

    var iTable = new GlideRecord('sys_import_set_row'); // add your import set table
    iTable.addQuery('sys_import_set', source.sys_import_set)
    iTable.query();
    var total = iTable.getRowCount();

    iTable.addEncodedQuery('sys_import_state=error^sys_import_set=' + source.sys_import_set); // will query only current import 
    iTable.query();
    var errorRec = iTable.getRowCount();

    gs.info(errorRec + "out of " + total + " resulted in error");

 

** Note : Get Row count is not recommended, use glide Aggeregrate , this code is just for reference.

 


Raghav
MVP 2023
LinkedIn

Ankur Bawiskar
Tera Patron
Tera Patron

@Mayuri S 

you can use onComplete transform script for this and send email via gs.eventQueue() approach

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader