Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Record producer load data using csv in scoped application

ibhati0991
Kilo Explorer

I tried in Global scope 

and  follwing script  from https://github.com/goranlundqvist/YouTube/blob/master/Episode%2016%20-%20Import%20data%20through%20R...

works fine

var transformMapSysIDs = '3a4a3c714fb7a300d99a121f9310c70f';//If you have more, separate them with , like 3a4a3c714fb7a300d99a121f9310c70f,3a4a3c714fb7a300d99a121f9310c703

current.name = gs.getUserName() + " UserImport at: " + new GlideDateTime();
current.import_set_table_name = 'u_import_record_producer';//Name of your import table
current.file_retrieval_method = "Attachment";
current.type = "File";
current.format = "Excel";
current.header_row = 1;
current.sheet_number = 1;
current.insert();//Need this since we want to load and transform directly

//Now it time to load the excel file into the import table

var loader = new GlideImportSetLoader();
var importSetRec = loader.getImportSetGr(current);
var ranload = loader.loadImportSetTable(importSetRec, current);
importSetRec.state = "loaded";
importSetRec.update();

//Time to run the the transform with the transform map
var transformWorker = new GlideImportSetTransformerWorker(importSetRec.sys_id, transformMapSysIDs);
transformWorker.setBackground(true);
transformWorker.start();

//To avoid to create another data source we abort the RP insert.
current.setAbortAction(true);

my question is in scoped application the import set loader and trasnformer worked classes are not available. what is the aletrnative?

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@ibhati0991 

check my blog and enhance the logic

Data load and transform via Catalog Item 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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