Service portal Ui Action

abhi56
Tera Contributor

In Service portal I want to create a Ui action which will directly download the record details in pdf format

I have tried to create using onclick function but it is not working in Service portal( as onclick does not work in Service Portal)

There is a context menu called Export to PDF,is there any way to use it as form button?

I am showing the record using form widget

1 REPLY 1

Samaksh Wani
Giga Sage
Giga Sage

Hello @abhi56 

 

Create a UI Action Button and add the below code :-

 

var rm = new sn_ws.RESTMessageV2();
rm.setHttpMethod('GET');
var url = gs.getProperty("glide.servlet.uri") + current.getTableName() + '.do?PDF&sys_id=' + current.sys_id;
rm.setEndpoint(url);
rm.setBasicAuth('account_id', 'account_password');
rm.saveResponseBodyAsAttachment(current.getTableName(), current.sys_id, current.number + ".pdf");
var response = rm.execute();
var httpResponseStatus = response.getStatusCode();
gs.log(httpResponseStatus);

 

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

 

Regards,

Samaksh