
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2025 10:45 PM
I am trying to get the attachment from one of the end point, the attachment is passed via base 64 encoded. I would like to know how to decode this and view this attachment.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 08:07 PM
Hi @Community Alums
Try following script according to your table
var attachment_name = ;//attachment name with extension
var contentType = ;//content type of the file(optional)
var incident_id = "sys_id of the incident";
var stringUtil = GlideStringUtil;
var attachment = new Attachment();
var value = attachment.write('incident', incident_id, attachment_name, contentType, stringUtil.base64DecodeAsBytes(base64 encoded string));
Thanks,
Swathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 08:07 PM
Hi @Community Alums
Try following script according to your table
var attachment_name = ;//attachment name with extension
var contentType = ;//content type of the file(optional)
var incident_id = "sys_id of the incident";
var stringUtil = GlideStringUtil;
var attachment = new Attachment();
var value = attachment.write('incident', incident_id, attachment_name, contentType, stringUtil.base64DecodeAsBytes(base64 encoded string));
Thanks,
Swathi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 09:16 PM
Hi Swathi,
1) I'm able to decode the base64 to binary data using the below code in screenshot . Can you help me to know what should I do next

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 09:56 PM
Thank you Swathi, this worked for me