Create Attachment from Content SStream
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 05:33 AM
Hi EveryOne,
I am getting StreamContent of an attachment in response body of ecc, Can any one let me know how to create an attachment from that ??
to Use New GlideSysAttachment().writeContentStream(gr,FILENAME,CONTENTTYPE,GlideScriptableInputStream stream)
the stream should be an object, i am unable to convert this response body i got into an object
Regards
Saran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 05:38 AM
Hello Saran,
I have used below script. check for your reference. What is your test case?
var StringUtil = GlideStringUtil;
var attachment = new Attachment( );
attachment.write('incident',target.sys_id,source.u_attachment_name,'',StringUtil.base64DecodeAsBytes(source.u_attachement_file));
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 05:38 AM
Hi Saran,
for creating attachments in ServiceNow you need to get the base64encoded data; then you can SOAP attachment creator for that and attachment will be added by system
what error you are getting when you are using that?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 06:05 AM
HI Anukur,
Some third party tool is sending stream content, basically it is binary, need to find a way to coinvert this to base64 or GlideScriptableObject to create an attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 08:58 AM
Hi Saran,
I don't think this would work with binary data. try telling them to send base64encoded data.
If I find anything will post.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader