Creating a word document from script

Susmitha14
Tera Contributor

Hi,

I am writing a background script. From that script Can I create a new word document and that document should be attached to a record through background script.

 

 

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Sushmita,

 

You can try something as below. 

var gr=new GlideRecord('sys_attachment');
gr.initialize();
gr.table_sys_id='sys_id_of_record'; //pass incident sys_id for a check
var gsa = new GlideSysAttachment(); 
var attachmentId = gsa.write(gr, "TestSample.doc", 'text/plain', "your text here");

Once done go to sys_attachment table & check for the file TestSample

View solution in original post

1 REPLY 1

Jaspal Singh
Mega Patron
Mega Patron

Hi Sushmita,

 

You can try something as below. 

var gr=new GlideRecord('sys_attachment');
gr.initialize();
gr.table_sys_id='sys_id_of_record'; //pass incident sys_id for a check
var gsa = new GlideSysAttachment(); 
var attachmentId = gsa.write(gr, "TestSample.doc", 'text/plain', "your text here");

Once done go to sys_attachment table & check for the file TestSample