We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Create new empty attachment, with no content

Ram_n Botelho
Tera Contributor

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

Brad Bowman
Mega Patron

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.

Rafael Batistot
Kilo Patron

hi @Ram_n Botelho 

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);

 

If this response was helpful, please mark it as Helpful and, if applicable, as Correct.
This helps other users find accurate and useful information more easily