How to create pdf by using UI action button for incident record and same pdf attached to same record

Brahmi Pandla
Tera Guru

How to create pdf  file by using UI action button(GeneratePDF) for incident record and same pdf attached to same record

 

---> Create UI action button called GeneratePDF on incident form

----> when click the GeneratePDF   pdf file will be generate 

---->pdf file will be attached to same incident record

 

 

Could you please provide solution with scripting

 

1 ACCEPTED SOLUTION

Manmohan K
Tera Sage

Hi @Brahmi Pandla ,

Create a UI action similar to below

 

ManmohanK_0-1683565596579.png

 

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

 

View solution in original post

5 REPLIES 5

Manmohan K
Tera Sage

Hi @Brahmi Pandla ,

Create a UI action similar to below

 

ManmohanK_0-1683565596579.png

 

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

 

I tried above code but I am not able to save ui action,getting syntax error 

After attached the pdf to incident, the same attachment need to docusign by using rest API

 

Could you please provide the steps and script if needed

 

 

How to include variables if we are creating for request item table