- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2018 04:53 AM
How to get attachment of incident record and convert that to base64 in scoped application.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2018 05:30 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2018 05:30 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2020 08:34 AM
It seems getContentBase64 works only in scoped application, not in global.
Quite strange.
Is there any alternative to it in global scope?
Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2020 10:06 AM
Refer this link where I have shared the approach for global scope
Regards
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
‎06-16-2023 12:21 PM
Hi Ankur! Is there a way to do this the other way around. So take a field that contains Base64 string and convert it back into an image (and then attach to the record)? Thank you in advance for your help!!