generate PDF with Purchase order details after clicking UI Action

R_52
Tera Guru

Hi,

 

I have a blank document and wanted to fill some fields from a record upon clicking some UI Action in ServiceNow form.

 

Please let me know if anyone has ideas or something how to generate a PDF with this.

2 REPLIES 2

SVimes
Kilo Sage

Here are some ideas:

 

  • Make the UI Action open a link which has a specific view of the record - example
  • Make the UI Action trigger a notification with the body precisely as you want it
  • Make the UI Action trigger a report that exports as PDF
  • Use the "Printer friendly version" in your profile menu from a specific view
Sable Vimes - CSA

Connectmustaq
Giga Guru

Hi @R_52 ,

 

You can generate a PDF with selected fields from a ServiceNow record using a UI Action. ServiceNow supports this via out-of-the-box export options, the PDFGenerator API, or third-party store plugins. Here are common approaches:

 

Method 1: OOB Export to PDF

  • Use the built-in Export > PDF function from the form's context menu.

  • Only fields shown in your current form view will be captured.

  • To customize which fields are present, adjust the view or use a dedicated view for exporting.​​

Connectmustaq_0-1762069451859.png

 

Method 2: PDFGenerator API (Advanced/Custom)

From Quebec release onwards, ServiceNow includes a PDFGenerationAPI to fill fields on a PDF template:

 

// Example for UI Action Script
var pdfTemplateSysId = '<sys_id of template PDF>';
var tableName = current.getTableName();
var recordSysId = current.getUniqueValue();
var pdfName = 'Generated_Document';

// Map record fields to PDF template fields
var fieldMap = {
"company": current.company.getDisplayValue(),
"employee": current.assigned_to.getDisplayValue(),
"ci": current.category.getDisplayValue(),
// Add more fields here
};

// Call PDFGenerationAPI to fill and generate PDF
var pdfGen = new sn_pdfgeneratorutils.PDFGenerationAPI();
var result = pdfGen.fillDocumentFields(fieldMap, pdfTemplateSysId, tableName, recordSysId, pdfName);

gs.info(JSON.stringify(result, null, '\t'));
// This will attach the generated PDF to the record[web:66]

 

  • You need a fillable PDF template uploaded to your instance

  • You can run this script via a UI Action (Form Button)

  • The generated PDF is attached to the record (visible in the Attachments)

Method 3: Store Plugin (PDF Generator by Sofigate)

  • The PDF Generator app enables PDF generation from records via a form button.​

  • This is a non-custom solution available from the ServiceNow Store.

Key Steps

  1. Create/upload a fillable PDF template (with mapped field names).

  2. Implement UI Action with PDFGenerationAPI for field mapping and generation.

  3. On button click, script pulls field values from the current record, fills the template, and attaches the resulting PDF.

Notes

  • Choose PDFGenerationAPI for most flexible, scripted, field-level control.

  • Simple requirements may be met with form view export, but layout and fields are less customizable.

  • Third-party plugins offer additional features without custom coding.

Let ServiceNow support or your developer team know your template requirements—they’ll help set up the template and field mapping for your business scenario.​