How to send attachment as a binary data as one of the parameter inside the body to the third party??

Manikantahere
Tera Contributor

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  ???

 

att-1.png

att-2.png

9 REPLIES 9

Najmuddin Mohd
Mega Sage

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.


NajmuddinMohd_0-1739302424824.png

 

 

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.

 

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. 

Manikantahere_0-1739355855617.png

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Manikantahere 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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?