Attachment to base64 in scoped application

Komal_D
Kilo Contributor

How to get attachment of incident record and convert that to base64 in scoped application.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Komal,

Following script should handle that: give the sysId in highlighted in bold

var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', '<incidentRecordSysId>');
gr.addQuery('table_name', 'incident');
gr.query();
if (gr.next()){
var sa = new GlideSysAttachment();
sa.getContent(gr);
var encodedData = sa.getContentBase64(gr);
gs.info("Base64 Encoded data is : "+encodedData);
}

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

@rcard11 

Can you create a new post and tag me there as this is an older thread?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader