Decode base64 image and add as attachment to the incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2025 12:57 PM
Hi All,
I am trying add a base 64 encoded attachment to the incident with below script. But it is not attaching the image.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2025 02:52 PM
You're using undocumented APIs.
Where is the content of current.u_image_data coming from?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2025 08:28 PM
Hi,
Data is coming through import sets mapping it to custom filed in servicenow to to decode and attach the image.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2025 09:44 PM
check my below comment and working logic
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2025 08:50 PM
writeBase64 works for scoped app
you are writing this code in global scope? are you writing this in onAfter transform script?
if yes then you can use SOAPAttachment Creator for this, something like this
var ecc = new GlideRecord('ecc_queue');
ecc.initialize();
ecc.agent = "AttachmentCreator";
ecc.topic = "AttachmentCreator";
ecc.name = "test.txt:text/plain";
ecc.source = "kb_knowledge:" + target.sys_id;
ecc.payload = source.u_base64Data;
ecc.insert();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader