Automating PDF reports
Learn how to build an App that lets users fill out and sign an acceptance report, save the submission to a relational database, and email it automatically as a PDF.
Before you begin
First, download the blank acceptance_report.pdf file. You will upload this file to the File Explorer to use as the template background.
You can build the App from scratch by following this guide, or start with the finished App logic by downloading the tag file below and importing it into your account. In that case you still need to link your uploaded PDF to the template.
Downloads
Step 1: Create the database table
Create a table in the internal relational database to store the submitted reports.
In the Backend Builder, drag the defineTable function onto the canvas and configure the inputs:
Trigger the function once to execute the logic and create the table in the database.

Step 2: Build the form and submission logic
Build the user interface for data entry, then configure the backend logic to save the submitted data to your database.
Build the user interface
Add the widgets for the form in the Frontend Builder.
Add the form widget
Drag a form widget onto the canvas. Configure its fields so the field names exactly match your database columns (customerName, projectID, acceptanceDate, comments). Define custom, user-friendly labels for each field.
Add the signature widget
Drag a signature widget onto the canvas and place it below the form.
Add the submit button
Drag a button widget below the signature widget and change its label setting to Submit.

Configure the submission logic
Switch to the Backend Builder to define the flow when a user clicks the Submit button.
Format the signature
The signature widget outputs a raw base64 string, but the database expects an object.
Drag a memory function onto the canvas and connect the output of the signature widget to its input.
Add a modifier extension node after the memory function. Configure it with the following expression to wrap the signature string in an object whose key matches the database column:

Combine the form data
Merge the main form data with the signature object.
Drag the
mergeObjectsfunction onto the canvas.Connect the form widget to the first input of
mergeObjects.Connect the signature modifier to the second input of
mergeObjects.Connect both inputs to the trigger of
mergeObjectsto trigger the functionon input update.

Save to the database
Drag the
addRowfunction onto the canvas.Set its
tableinput toacceptanceReports.Connect the output of
mergeObjectsto thedatainput ofaddRow.Connect the Submit button to the trigger of
addRow. The button now starts the entire save process.

Step 3: Design and configure the PDF template
With the data submission logic in place, create the visual PDF template and configure the logic to populate it.
Design the template layout
Create the visual layout in the PDF Template Editor.
Upload the background PDF
Upload the acceptance_report.pdf file to the file server via the File Explorer.
Open the PDF Template Editor
Navigate to the PDF Template Editor.

Configure the PDF generation logic
Return to the Backend Builder to connect the template to your existing logic.
Add the fill function
From the Function Explorer, find your AcceptanceReport instance (under the PDF templates class) and drag its fillTemplate function onto the canvas.
The flow is now complete up to the point of generating the PDF. The final step is to email this document.

Step 4: Send the report via email
Automatically email the generated PDF report using the send function of the internal email connector, triggered whenever a new report is created.
Return to the Backend Builder to add the final piece of logic to your flow.
Format the attachment data
The send function's attachment input requires a specific object format. Create it directly on the output of fillTemplate.
Add a JSONata modifier extension node to the
fillTemplatefunction.Enter the following JSONata expression. It wraps the raw base64 output (
$) with a filename and encoding:
This creates a data-driven workflow: whenever fillTemplate generates a new PDF, its output is passed to the attachment input, and this change automatically triggers the send function.

Step 5: Deployment
Congratulations! 🥳 You have built a complete App that captures user input, saves it to a database, generates a customized PDF, and emails it as an attachment.
Click the Deploy button in the App Builder's Top Bar to publish the latest version and make it live.
Once deployed, open the App and test the full workflow. After you fill out and submit the report, the email address you configured in Step 4 receives an email with the PDF attachment, similar to the image below.
From here, you can expand the project by adding more fields, using your own report templates, or integrating this logic into a larger App.

Last updated
Was this helpful?
