How can I create an attachment from script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2017 06:28 AM
Does SN offer any API to create an attachment? I've used the following:
var gsa = new GlideSysAttachment(); var attachmentId = sa.write(gr, "fileName.txt", 'text/plain', "some data");
This works fine for creating text files. It doesn't work when trying to create a pdf, doc or docx file. Is there a way to do so?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2017 02:47 AM
Hi,
This looks like it's the same problem as discussed in Any get GlideSysAttachment.write to work for binary files while in a scope?
Perhaps if you have access to an Istanbul instance you can see if it's been fixed as describe in the thread above.
Kind regards,
Phonsie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2017 10:14 AM
Joseph,
We are glad you took advantage of the ServiceNow Community to learn more and to get your questions answered. The Customer Experience Team is working hard to ensure that the Community experience is most optimal for our customers.
If you feel that your question was answered, we would greatly appreciate if you could mark the appropriate thread as "Correct Answer". This allows other customers to learn from your thread and improves the ServiceNow Community experience.
If you are viewing this from the Community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thanks,
Shivani Patel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 12:34 AM
Hi cap,
Could you please send me that working fine script fot text files. its argent

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 01:27 AM
Hi,
For creating a pdf, you have to use PDF generator code in service now. GlideSysAttachment wont create pdf for you,
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 01:30 AM
Hi Thanks for your reply please send that PDF generator code,and were it in servicenow