How to send attachment as a binary data as one of the parameter inside the body to the third party??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 08:06 AM
When I tried to use the below code to convert the attachment to binary data I got the error. When explored more on the error I found the article saying this will only work scope other than global. is it right? if not how can I convert the attachment into binary data to send it to third-party ???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 11:36 AM
Hello @Manikantahere ,
There is table sys_attachment_doc.
Navigate to sys_attachment_doc.LIST and check the attachment you have added. Check the data field value.
If this is the value that you are expecting, then you do not need to write any code. Just GlideRecord this table and filter with the attachment and get the data.
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 02:24 AM - edited 02-12-2025 02:46 AM
Thanks for your reply.
I am not sure about it and I need to check whether it works or not however even if I want to glide the particular records multiple requestors might attach same file then how should I glide correct record to get the data field value?
ex. you can see below multiple records are having same file name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 02:51 AM
that's correct, your script will work only in global scope.
For scoped app use this
Ensure you give correct record sysId from sys_attachment
var gr = new GlideRecord('sys_attachment');
gr.get('3fd6017407d3dc50540bf2508c1ed027');
var sysAtt = new GlideSysAttachment();
var base64Data = sysAtt.getContentBase64(gr);
gs.info(base64Data);
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
02-12-2025 02:54 AM - edited 02-12-2025 02:55 AM
Thanks for your response,
Let me convey it in different manner the error it shows is flow can't read the property and when I explored about error they are saying that API doesn't work in Global scope.
I am writing code and flow in Global only. BTW the error also generated in Global only?