How to send attachments to 3rd party system through Base64?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 11:16 PM
Hi,
We are integrating with 3rd party system flow designer for sc_req_item table, we need to pass the attachment to them in base64 format. In the script action in the flow ,used the below code but returning null to me.
The 'attach' variable is returning null.
How to fix this?
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 11:37 PM
Hello @User205031
Check this thread:
Solved: Re: Converting attachment to base64 in Flow Design... - ServiceNow Community
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 11:46 PM
Hi @User205031
You can try below code:-
table= sys_attachment;
record=record;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 11:53 PM
flow is in which scope?
the getContentBase64() method is only for scoped app, so if your flow is for scoped app then it should work fine provided the sys_attachment record is found and the output variable is mapped correctly
For global scope use this
var attGr = new GlideRecord('sys_attachment');
attGr.addQuery('table_sys_id', inputs.bulk_csv);
attGr.query();
if(attGr.next())
{
var gsu = (typeof GlideStringUtil != 'undefined') ? (GlideStringUtil) : (Packages.com.glide.util.StringUtil); //few versions support the first one, other supports second
var gsa = (typeof GlideSysAttachment != 'undefined') ? (new GlideSysAttachment()) : (new Packages.com.glide.ui.SysAttachment());
var attachmentData = gsa.getBytes(attGr);
var attachment = String(Packages.java.lang.String(attachmentData));
var encData = GlideStringUtil.base64Encode(attachmentData); // data of one attachment at a time
outputs.attach = encData;
}
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 03:54 AM
Hope you are doing good.
Did my reply answer your question?
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