- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2017 11:57 PM
Hi,
I need to achieve two things:
1> Call a Import set from catalog item workflow.
2> This import set should create as many requested item (RITM) records in servicenow as there are rows in the attached excel file during the time of ordering the catalog item.
Any code that can achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 12:56 AM
Hi Amit,
Sample script below:
2) Copy the attachment from RITM to the data source record using GlideSysAttachment() copy
GlideSysAttachment.copy('sc_req_item', current.sys_id, 'sys_data_source', '<dataSourceSysId>');
3) Trigger the scheduled data import from workflow script and it should start the transform map etc
var exportGr = new GlideRecord("scheduled_import_set");
exportGr.addQuery("sys_id", "<RecordSysId>"); // sys_id of the record which you will be creating for scheduled data import
exportGr.query();
if (exportGr.next()) {
gs.executeNow(exportGr); // this is for scoped app
// SncTriggerSynchronizer.executeNow(schImp_GR); // this is for non scoped app
}
Mark Correct if this solves your issue and also hit Like and 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
‎11-20-2017 12:40 AM
Hi Amit,
I assume you want to run data source and load some records.
1) Create Scheduled Data Import for this data source and make this active false
2) Copy the attachment from RITM to the data source record using GlideSysAttachment() copy
3) Trigger the scheduled data import from workflow script and it should start the transform map etc
Mark Correct if this solves your issue and also hit Like and 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
‎11-20-2017 12:46 AM
Hi Ankur,
Thanks for your response. I know this process but was looking for the code that can help me. Could you please provide a sample script (need not to be exact) for the below two points :
2) Copy the attachment from RITM to the data source record using GlideSysAttachment() copy
3) Trigger the scheduled data import from workflow script and it should start the transform map etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 12:56 AM
Hi Amit,
Sample script below:
2) Copy the attachment from RITM to the data source record using GlideSysAttachment() copy
GlideSysAttachment.copy('sc_req_item', current.sys_id, 'sys_data_source', '<dataSourceSysId>');
3) Trigger the scheduled data import from workflow script and it should start the transform map etc
var exportGr = new GlideRecord("scheduled_import_set");
exportGr.addQuery("sys_id", "<RecordSysId>"); // sys_id of the record which you will be creating for scheduled data import
exportGr.query();
if (exportGr.next()) {
gs.executeNow(exportGr); // this is for scoped app
// SncTriggerSynchronizer.executeNow(schImp_GR); // this is for non scoped app
}
Mark Correct if this solves your issue and also hit Like and 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
‎11-20-2017 04:23 AM
That worked perfectly. Thanks