Export to pdf in the HR case should export fields with value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:57 AM
Hi,
I need to create a Ui action to print the HR case only if the field has a value, fields with empty or no value is not required while clicking on "Print" ui action. Can anyone help me on this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 06:18 AM
@Community Alums You can use a UI Action to prepare HTML from the fields which have data on them and use the PDFGenerationAPI (https://developer.servicenow.com/dev.do#!/reference/api/rome/server/sn_pdfgeneratorutils-namespace/PDFGenerationAPIBothAPI) to generate the PDF from it. Here the example quoted at the shared URL.
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
// (Option) get HTML from the description field of an incident record
var gr = new GlideRecord("incident");
var html;
if (gr.get("<tableSysId>")) {
html = gr.description.toString();
}
var result = v.convertToPDF(html, "incident", "<target_sys_id>", "myPDF");
gs.info(JSON.stringify(result));
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 06:24 AM
Hi @Community Alums ,
This is the Out of Box, designed behavior as only fields on the form and their values are carried over to the PDF.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 06:34 AM
Hi @Community Alums , I had few fields which are hided on the case form through client script and ui policy and they don't have any field value but when exported to pdf those were also getting exported so I need to export to pdf only the fields which has value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 06:38 AM
Hi @Community Alums ,
Unfortunately, even those fields would get exported with blank values.