- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 03:41 AM
Hello Everyone,
Does anyone here already done an auto-import from an attached excel file on RITM using workflow script? We are trying to build a Service Catalog Item to automatically add/update/remove locations by auto-importing user's attached excel file. Reason why we want to use RITM so that Data Management team can verify if the data on the attached file is correctly filled out. After closing the catalog task, we want to run the script to auto-import the attached excel file. Thank you in advance.
Diane.
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 06:25 AM
Hi Diane,
So this is what might be happening; by the time the attachment is getting copied the code to trigger the transform map might be triggering
so either do these
1) copy the attachment in workflow run script first then wait then use run script to trigger
2) or else create after insert business rule on sys_attachment table and condition as table_sys_id is your data source sys id
have the code to trigger the transform map in that BR
var dataSourceSysId = '266fc888dbb9770013c7757a8c961954';
var schedImp = new GlideRecord('scheduled_import_set');
schedImp.addQuery('data_source',dataSourceSysId);
schedImp.query();
if(schedImp.next()){
gs.executeNow(schedImp);
}
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
‎05-29-2019 06:04 AM
Hi Diane,
Is the attachment getting copied properly? check this first.
Also are you executing this in scoped app?
Did you have field map so that you can map the source fields with target fields
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
‎05-29-2019 06:22 AM
Hi Ankur,
Yes, the attachments are getting copied correctly to the data source. No, I am not using scoped app. Field maps are also created.
Regards,
Diane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 06:25 AM
Hi Diane,
So this is what might be happening; by the time the attachment is getting copied the code to trigger the transform map might be triggering
so either do these
1) copy the attachment in workflow run script first then wait then use run script to trigger
2) or else create after insert business rule on sys_attachment table and condition as table_sys_id is your data source sys id
have the code to trigger the transform map in that BR
var dataSourceSysId = '266fc888dbb9770013c7757a8c961954';
var schedImp = new GlideRecord('scheduled_import_set');
schedImp.addQuery('data_source',dataSourceSysId);
schedImp.query();
if(schedImp.next()){
gs.executeNow(schedImp);
}
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
‎05-29-2019 06:50 AM
Thanks Ankur, that worked perfectly!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2020 03:43 AM
Hi Ankur,
Can I get the current RITM number in the transform script.
I am creating catalog tasks based on number of rows in the attachment. So I want those catalog tasks RITM to be the one from the worfklow.
Mounika