Service portal Ui Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2023 09:39 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2023 09:40 PM - edited ‎12-10-2023 09:40 PM
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