- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2019 07:29 AM
We have a data source where we manually attach an attachment.This Data Source is associated with a 15 minute periodically executing Scheduled Data Import.The attachment is related to sys_user table.After the attachment upload[after the scheduled data import execution],If I manually change any user record data ,the data source attachment overrides the value as the Scheduled data import runs again after 15 mins.
Is there a way to delete an attachment once its executed by the scheduled data import?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2019 07:45 AM
Hi Amala,
you can have following script in the post execute script which would run once the transform runs so that older attachment is deleted and new one can be attached.
you need to set the checkbox of execute post-import script
var dataSourceSysId = ''; // give here the data source sys id
var remAtc = new GlideRecord('sys_attachment');
remAtc.addQuery('table_name', 'sys_data_source');
remAtc.addQuery('table_sys_id', dataSourceSysId);
remAtc.query();
remAtc.next();
remAtc.deleteMultiple();
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
‎07-11-2019 07:45 AM
Hi Amala,
you can have following script in the post execute script which would run once the transform runs so that older attachment is deleted and new one can be attached.
you need to set the checkbox of execute post-import script
var dataSourceSysId = ''; // give here the data source sys id
var remAtc = new GlideRecord('sys_attachment');
remAtc.addQuery('table_name', 'sys_data_source');
remAtc.addQuery('table_sys_id', dataSourceSysId);
remAtc.query();
remAtc.next();
remAtc.deleteMultiple();
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