Get all sys_ids of attachments for an incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 01:25 AM
Ho can i get all sys_ids of the attachments for a particular incident?
my goal is to write a script to download the attachments one by one using curl command
There are a lot of attachments assigned to one incident and I want to get all the sys_ids(may be using a query) for the attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 03:20 AM
Hi parvbionics,
Please check the below script.
Using this script you will be able to extract the sys ids of attachments from particular incident.
var sysid='sys_id of incident';
//var sysid=current.sys_id;
var arr=[];
var gAttach=new GlideRecord('sys_attachment');
gAttach.addQuery('table_sys_id',sysid);
gAttach.query();
while(gAttach.next())
{
arr.push(gAttach.getValue('sys_id'));
}
gs.log("Attachments sys ids '+arr);
You can refer the below link to get an idea how we can download the attachments using curl.
If my answer help you to resolve your issue then please don't forget to mark correct or helpful.
Regards,
Devender