Export fields and Variables on the form in pdf format

Kalyani35
Tera Guru

Hi experts,

 

I have a requirement where I need to have a UI action to export the fields, related list as well as Variables present on the HR case form. With the OOB UI action, the variables are not exported to pdf.

An alternative is to use the PDFGenerationAPI, using which I can create a pdf having variables, but not sure how can I manage the export of the fields on HR case form in the same pdf as there would fields and related list that need to be exported too.

Does anyone have implemented anything similar to this?

 

Thanks

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Kalyani35 

you can create UI action with this line in the onClick function. this does exactly the same what printer friendly version does

it will include fields, variables, related list

printList('25000');

UI Action will look like this

AnkurBawiskar_0-1676543108143.png

 

 

print.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✹ Certified Technical Architect  ||  ✹ 9x ServiceNow MVP  ||  ✹ ServiceNow Community Leader

Hi Ankus,

Thanks for your reply. 

I added it in UI action as you mentioned, but I would like to have this UI action on the Agent workspace, and it did not work. Do you see something wrong here?

Kalyani35_0-1676543873507.png

 

Also, would it show variables in the pdf if they are made visible on condition. With Printer friendly version I observed, it does not show the variables which are visible conditionally(even when they are visible on the form).Looks like UI policy/ CS does not apply here while export.

 

Thanks 

If someone is still searching for a solution, You can use the below script under workspace client script on UI action

function onClick(g_form) {
    //Retrieve current record table name and sysID
    var table = g_form.getTableName();
    var sys_id = g_form.getUniqueValue();
    var url = "/"+table+".do?sys_id="+sys_id+"&sysparm_force_row_count=999999999&sysparm_media=print&sysparm_use_polaris=false";
   
    //Open url
    var win = open(url,"_blank");
    win.focus();
}