PDF Application Guide

Definition

Overview

During this phase, you will use a PDF that is fillable and unprotected. This PDF allows you to only fill in data fields without encryption, password protection, or protected areas of the PDF. This is required, as UXstorm PDF will be making modifications and must be allowed to do so.

In this phase, you will create a new UXstorm PDF -> Form, attach the PDF formally mentioned, and associate this Form to a ServiceNow Table. You will now see many options available on the Form, which we will discuss later.

At this point, the "Get Fields" button will work and pass the form to a MID server to process. When done, all fields on that Form will be added to the current Form.

By default, no fields are mapped. It now a process of specifying which fields are to be mapped, and how. Each field to be mapped is flagged and the specific mapping technique is specified. This will depend greatly upon the PDF field type. The different types of mappings are Direct, Conditional, Template, Memo, Script, or Mapping (for choices).

Once all the fields are mapped, the form can be produced. When it is produced depends on whether the form is Conditional or NonConditional. The produced PDF is attached to the generating ServiceNow record as a PDF attachment. Each form can specify how to handle this attachment – from allowing for a single attachment of this PDF to versioning each generation of the PDF.

PDFs > 3.5 Meg Support (Large PDF Support)

ServiceNow limits the attachment/memory size of files and in doing so, the Out of Box limit for a PDF being generated by UXstorm PDF Forms is 3.5 meg. With the release of 4.0, Large PDF file support has been added. This sends and receives all PDFs as attachments through the MID Server instead of putting them into the ECC Queue. This means support of PDFs of up to 50 meg has been tested. The actual limit is how fast the PDF can be transferred between the MID Server and the instance before it is timed out.

To enable the support goto UXstorm PDF Forms -> Administration -> Properties and enable Support PDFs greater than 3.5 Meg.

Breaking change if selected. Selecting Large PDF support will cause any scripts that contain a variable with the PDF Content in Base64 to change. Because of the large size, the contents cannot be provided in a string. In these cases, the sys_id of the PDF file attachment in sys_attachment, is provided and you can use the ServiceNow routines to work with attachments to move or read the information. This affects places like Pre/Post Attach Scripts.

What is a non encrypted/protected PDF file?

UXstorm PDF application can only use these files for the templates so what are they? A PDF can be password protected and encrypted. To open the PDF, you must know the password. Also, the form can be protected, or areas protected, from change. These two options are done during the creation of the PDF. Both prevent UXstorm PDF from making modifications to the form and thus using it as a template.

Producing the PDF using data from ServiceNow

Conditional Forms

If a Form is specified to be Conditional, then a condition on the ServiceNow form is specified. Whenever a record on the table is updated or inserted, that condition will be evaluated. If the condition is true, then the PDF Form is generated using the updated/inserted record for the mapping. The mapping is performed on the Instance, and then sent to a MID Server to generate the PDF with the data. When done, the PDF is created and attached to the record.

This is an example of a conditional that causes the PDF to be generated whenever the State changes. This is the normal condition control used throughout ServiceNow and the condition can be simple to complex.

pdf-definition-filter.png

NonConditional Forms

A Form is considered NonConditional if a condition is not required to generate the form. The PDF will only be generated from a ServiceNow script. Example scripts are Business Rules and UI Actions. A nonconditional script can be generated one of two ways. By specifying the exact PDF Form to generate, or from generating all noncondiational forms for a current record.

Each method will use x_uxs_pdf.PDF() function to generate the PDF(s). The difference is the arguments.

To generate a specific form for a current record:

var createPDF = new x_uxs_pdf.PDF(current,"single","a6abc659db4a474019cafbb9af961947");

The second argument must be "single" and the third is the sys_id of the UXstorm PDF Form record of the form to be generated.

To generate all non-conditional forms for a current record:

var createPDF = new x_uxs_pdf.PDF(current,"nonconditional","");

The second argument to x_uxs_pdf.PDF() is "nonconditional" and the third is a blank string.

A full function example of a UI Action to create all nonconditional PDFs for a record:

current.update();
var createPDF = new x_uxs_pdf.PDF(current,"nonconditional","");
if (!createPDF.getStatus()) {
    gs.addErrorMessage("Could not create PDF");
} else {
    action.setRedirectURL(current);
}

Production of the PDF Form

The first phase of the PDF production happens on the ServiceNow Instance. The originating ServiceNow record is used as input to the Form for all the data mapping specified in the UXstorm PDF Form. Once the mapping is done, this is sent to a ServiceNow MID Server. The MID Server will produce the required PDF and send back the finished product. This PDF is then attached to the originating ServiceNow record.

The resulting PDF can be in one of three different formats.

  1. A fillable unprotected PDF (alike to the original) but with all its data in the appropriate mapped fields.
  2. Flattened so the data permanently appears in the appointed fields, removing the fillable option. This will guarantee no further changes can be made to the PDF.
  3. Protected via Password and Encrypted. The PDF is encrypted and can only be opened if you know the Password used to generate the PDF.