- 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
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
04-22-2020 11:39 AM
Ankur,
Again we have to configure Read Access to the "scheduled_import_set" table from scoped application. We dont want this. What needs to be done here.
Thanks,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 08:18 PM
Hi Rahul,
what is the exact issue faced?
Regards
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
04-23-2020 06:48 AM
Again, the issue is same which was asked in the another community post. OTB the scheduled import set table did not have accessibility from all apps.