Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Modify a word document when a RITM is submitted

Nagashree5
Tera Contributor

Hi All,

 

Can we open a word document and replace the text in the document in ServiceNow>

Please suggest.

 

Thanks in Advance.

2 REPLIES 2

Samaksh Wani
Giga Sage

Hello @Nagashree5 

 

Use the below code related to your use case/requirement :-

 

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

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Hi @Samaksh Wani,

 

Thanks for the response.

The word document is getting created but seems like the file is corrupted and also here I have to replace few words in the word document to different words, is it possible to modify the doc by replacing few words.

Please suggest.