Open an attachement with script

demgnekamdem
Tera Contributor

Hi all,

How can I improve the following script to open my attachment and display file on my screen

 

var attachment = new GlideSysAttachment();
var agr = attachment.getAttachments('incident', 'e8caedcbc0a80164017df472f39eaed1');
while(agr.next())
gs.info(agr.getValue('file_name'));

 

Thanks in advance,
Carole

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

Hi @demgnekamdem 

Where did you writing this script?
Recently, I have achieved this requirement in one of the form using UI Action. Please find below logic it may help you and it will open the attachment in new tab.

var ins = 'https://<INSTANCE NAME>.service-now.com/'; 

url = ins + 'sys_attachment.do?sysparm_referring_url=tear_off&view=true&sys_id=' + "ATTACHMENT SYS_ID";
g_navigation.openPopup(url);

Before doing this you must activate the below property:

com.snc.documentviewer.enable_document_viewer

If not present, create new property with the above name and set value as "true"

 

Hope it helps..

Thanks,
Murthy

View solution in original post

1 REPLY 1

Murthy Ch
Giga Sage

Hi @demgnekamdem 

Where did you writing this script?
Recently, I have achieved this requirement in one of the form using UI Action. Please find below logic it may help you and it will open the attachment in new tab.

var ins = 'https://<INSTANCE NAME>.service-now.com/'; 

url = ins + 'sys_attachment.do?sysparm_referring_url=tear_off&view=true&sys_id=' + "ATTACHMENT SYS_ID";
g_navigation.openPopup(url);

Before doing this you must activate the below property:

com.snc.documentviewer.enable_document_viewer

If not present, create new property with the above name and set value as "true"

 

Hope it helps..

Thanks,
Murthy