Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Attachment API GET method

ServiceNow10sun
Giga Guru

Hi All, 

 

I have requirement to  edit the existing attachment API on Incident table to get the count of attachments instead of getting the content of the attachment , as currently in the response it is giving the content of the file. 

 

Could you please suggest where i need to edit or search for the attachment API . 

I didnt found any details in scripted REST API , REST messages .  

2 REPLIES 2

Bhavani Shankar
Tera Guru

Hi,

This script would give you the count of attachments on the incident record

var attachment = new GlideSysAttachment();

var agr = attachment.getAttachments('incident', '<record_sys_id>');
var count = 0;
while(agr.next()){
      count += 1;
}
gs.info(count);
//count variable will have the number of attachments of your record of interest

 

If this response was helpful, please leave a thumbs up

 

Regards,

Bhavani Shankar

Regards,
Bhavani Shankar
Linked In

Hello @ServiceNow10sun ,

 

Please mark my response helpful, if it really helped.

 

Thanks in advance.

 

Regards,

Bhavani Shankar

 

 

Regards,
Bhavani Shankar
Linked In