Export PDF with only few fields

harshaa0567
Tera Contributor

Hi,

 I have a requirement to create a UI button on the form that Should export only a particular section on the form. For example in incident form I want to export only "resolution notes" section as PDF.

 Can anyone please provide me the solution for it.

 

Thanks in advance

1 ACCEPTED SOLUTION

VaishnaviK43271
Tera Contributor
    var pdf = new sn_pdfgeneratorutils.PDFGenerationAPI();
    var html;
    var gr = new GlideRecord("incident");
    if (gr.get(current.sys_id)) {

        html = "<html><body>";
        html += "<h2>Resolution Notes</h2>";
        html += "<p><b>Incident:</b> " + gr.number + "</p>";
        html += "<p><b>Short Description:</b> " + gr.short_description + "</p>";
        html += "<hr>";
        html += "<p>" + (gr.close_notes || "No resolution notes available.") + "</p>";
        html += "</body></html>";

        var result = pdf.convertToPDF(html, 'incident', current.sys_id, "Incident Pdf");

        if (result.status ==='success' && result.attachment_id) {
 
            var downloadURL = '/sys_attachment.do?sys_id=' + result.attachment_id;
            var gURL = new GlideURL(downloadURL);
            action.setRedirectURL(gURL);
            //action.setReturnURL(url);
            gs.addInfoMessage("PDF generated successfully.");

        } else {
            gs.addErrorMessage("PDF generation failed.");

        }
    }

 

Screenshot 2025-12-08 122040.png

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for.

Thank You

View solution in original post

10 REPLIES 10

Hi @harshaa0567 ,

If my solution helps you then mark it as helpful and accept as solution.