- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 03:10 AM
Hi All,
It is possible to create a PDF file using ui action in the incident form. Once the user save or submit the form all the fields should come the PDF file .
Can anyone provide me the script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 03:19 AM
Hi @chandan31
Yes, you can do it. You will need create a user which will do pdf export. Create a UI Action like below-
Then Enter below code in the script section of UI action-
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);
Ensure that you create a user account and enter the id and password for the user account in the 5th line of code.
Optional - Feel free to replace 5th line with below line after setting up 2 system properties, a username and a password that correspond to a user account that is used to generate the PDF.
rm.setBasicAuth(gs.getProperty('pdf.export.username'), gs.getProperty('pdf.export.password'));
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 03:19 AM
Hi @chandan31
Yes, you can do it. You will need create a user which will do pdf export. Create a UI Action like below-
Then Enter below code in the script section of UI action-
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);
Ensure that you create a user account and enter the id and password for the user account in the 5th line of code.
Optional - Feel free to replace 5th line with below line after setting up 2 system properties, a username and a password that correspond to a user account that is used to generate the PDF.
rm.setBasicAuth(gs.getProperty('pdf.export.username'), gs.getProperty('pdf.export.password'));
Please mark my answer helpful and correct.
Regards,
Amit