Create new empty attachment, with no content

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi.
I am trying to create a new empty file, with no content, but the following method only works if content is filled.
Does anyone have any idea of how can I get it, please?
var attachment = new GlideSysAttachment();
attachment.write(grTask, fileName, 'text/plain', content);
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago - last edited 4 hours ago
I have gotten this to work using ' ' (one space) as the final argument. There's probably a Business Rule, System Property, or check in the script method preventing 0 byte file sizes.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
If you really want to create a file with no content (0 bytes), you can do it like this:
var attachment = new GlideSysAttachment();
var emptyContent = ''; // nothing inside
attachment.write(grTask, fileName, 'text/plain', emptyContent);