Create an error file when an import is failed in transform map.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader