How to get the content of an Attachment?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2017 06:03 AM
I uploaded a simple text file to an Incident and want to retrieve the content through javascript to pass it over an external rest call.
I'm using the following code as explained by the docs, but they do not seem to be working.
var att = new GlideRecord('sys_attachment');
att.get('file_name', 'Test.txt');
gs.print(att.getDisplayValue() + '***' + att.size_bytes + '***' + att.content_type);
var sa = new GlideSysAttachment();
var content64 = sa.getContentBase64(att);
gs.print(content64);
var content = sa.getContent(att);
gs.print(content);
My output is:
*** Script: Test.txt***11***text/plain
*** Script: undefined
*** Script: undefined
Additionally, the documentation stated that only 5MB is returned through the getContent functions. What if the document is larger than that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2024 10:49 PM
Please post a new question and tag me there as this is an old thread.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2024 01:35 AM