- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2022 05:17 AM
can some one help me with the script where it need to check if there is any attachment to the defined data source , if yes delete that attachment
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2022 05:40 AM
Hi the below should work in Run script activity of the workflow:
var gr = new GlideRecord('sys_data_source.');
gr.addQuery('sys_id', 'Sys id of the data source');
gr.query();
if (gr.next()) {
var attach = new GlideSysAttachment();
attach.deleteAll(gr);
}
Please mark the answer correct/helpful if it resolved your issue.
-Krupa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2022 05:40 AM
Hi the below should work in Run script activity of the workflow:
var gr = new GlideRecord('sys_data_source.');
gr.addQuery('sys_id', 'Sys id of the data source');
gr.query();
if (gr.next()) {
var attach = new GlideSysAttachment();
attach.deleteAll(gr);
}
Please mark the answer correct/helpful if it resolved your issue.
-Krupa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 06:37 AM
Hi RudraKAM,
May I know if the answer suggested was correct and helpful?
If yes, please mark the same or let me know in case of any additional questions.
-Krupa.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2022 05:41 AM
Hi,
I am not sure if I have understood your requirement correctly but below is the API available in ServiceNow to delete any attachments.
var attachment = new GlideSysAttachment();
var attachmentSysID = 'a87769531b0820501363ff37dc4bcba2'; //Attachment's sys_id.
attachment.deleteAttachment(attachmentSysID);
Reference link -
https://developer.servicenow.com/dev.do#!/reference/api/rome/server/no-namespace/c_GlideSysAttachmentScopedAPI#r_SGSA-deleteAttachment_S?navFilter=attachment