- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2019 12:36 AM
Hi All,
We are facing an issue wherein the below code works fine in Global Application but in scoped application I am getting the error that GlideImportSetLoader() and GlideImportSetTransformerWorker is not supported.
Can you please assist?
var transformid='b8b0e805db0233007feff53a29961938';
var gr=new GlideRecord('sys_data_source');
gr.name=gs.getUserDisplayName();
gr.import_set_table_name='u_import_source';
gr.file_retrieval_method="Attachment";
gr.type="File";
gr.format="Excel";
gr.header_row=1;
gr.sheet_number=1;
var sysID = gr.insert();
GlideSysAttachment.copy('sc_req_item', current.sys_id, 'sys_data_source', sysID);
// to load data in import set table
var loader=new GlideImportSetLoader();
var importSetRec=loader.getImportSetGr(gr);
var ranload=loader.loadImportSetTable(importSetRec, gr);
importSetRec.state="loaded";
importSetRec.update();
//to run transform with transform map
var transformworker =new GlideImportSetTransformerWorker(importSetRec.sys_id,transformid);
transformworker.setBackground(true);
transformworker.start();
gs.addInfoMessage("Your import file has been submitted");
BR,
Ankur
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2019 12:55 AM
Hi Ankur,
that won't work in global scope. 2 approaches you can have
1) have this code in script include which will be in global scope and accessible from all application scope and call it from your above code
2) remove that code and create scheduled data import for that corresponding data source and keep it active false; trigger the data import via script below
var schImp_GR = new GlideRecord('scheduled_import_set');
schImp_GR.addQuery('sys_id','<yourRecordSysIdHere>'); // put sys_id of the scheduled data import just now created
schImp_GR.query();
if(schImp_GR.next()){
gs.executeNow(schImp_GR);
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2020 03:45 AM
Hi Ankur,
I have done the same what you said like create a script include in global and make it accessible from all application scopes and called it from record producer script but I am getting the errors and importing is not performed. showing error like processexcelinscope, undefined may be missing global qualifier(refer the attachment screenshot94).
processexcelinscope is script include what I have created.
Also while uploading the data from excel data source record is created with the values mentioned in recordproducer script but there is another field named path for each row which is mandatory field(reer screenshot95) I didn't get what that field about.
Thanks & Regards,
varaprasad kandula.