Skip to main content
Question

Document creation - Save PDF to field in record

  • Oct 3, 2024 6:14 PM UTC
  • 4 replies
  • 1437 views

Forum|alt.badge.img

Loving the new Document creation feature, but now I want to expand upon it and save the generated PDF to a file attachment field on the form. The feature just makes an API call and the PDF is returned in the response, so we should be able to build a Pipeline to iterate through the JSON response and save the PDF. I've been trying to set this up for a few days, but to no avail.

Has anyone done this yet? 

4 replies

Forum|alt.badge.img+3

Yes, I'll give you the info but I can't take the credit.  Taylor Hardy at Quickbase did the work. In this case, we use it to send to Outlook, but you can change it to a file attachment field.

 Here is the yaml:


# Doc Gen Testing
#

# Account slugs:
#  - quickbase[CHANGE ME]: Realm Default Account <None>
#  - microsoft-outlook[CHANGE ME]:
#    <None>
---
- META:
    name: Doc Gen Testing
- ACTION quickbase[CHANGE ME] quickbase_api make -> a:
    inputs:
      method: GET
      url: https://api.quickbase.com/v1/docTemplates/1/generate?tableId=DBID_CHANGE_ME&format=pdf&pageSize=Letter&filename=Invoice&margin=1
        1 1 1&unit=in&orientation=portrait&recordId=1
    name: Generate Doc
- ACTION quickbase[CHANGE ME] quickbase_api make -> b:
    inputs:
      body: "{\n    \"to\": \"CHANGE_ME_TABLE_ID\",\n    \"data\": [\n      {\n        \"6\"\
        : {\n            \"value\": {\n                \"fileName\": \"{{a.json.fileName}}\"\
        ,\n                \"data\": \"{{a.json.data}}\"\n              }\n      \
        \  }\n      }\n    ],\n    \"fieldsToReturn\": []\n  }\n      }\n    }\n \
        \ ]\n}\n    \"fieldsToReturn\": []\n  }"
      method: POST
      url: https://api.quickbase.com/v1/records
    name: Save File to a Table
    note: 'Write the record '
- LOOKUP quickbase[CHANGE_ME] record look_up -> c:
    inputs-meta:
      table: '"Demo App: Invoice Files" <CHANGE_ME>'
      export_fields: '"File" <6>'
    inputs:
      id: '{{b.json.metadata.createdRecordIds[0]}}'
- ACTION microsoft-outlook[CHANGE_ME] email send_email_attachment -> d:
    inputs-meta:
      attachments:
        name: '{{c.file.file_name}}'
        url: '{{c.file.file_transfer_handle}}'
    inputs:
      body: Testing writing doc to QB table, looking up that record to get the file
        transfer handle, then emailing it using the outlook channel
      subject: Doc Gen Testing
      to_addresses: CHANGE_ME
...


KeithJusas
Forum|alt.badge.img+7
  • Qrew Cadet
  • Oct 10, 2024 7:03 PM UTC

If you are looking to save the generated document in a file attachment field when using the new Document Creation functionality and the yaml code scares you...we got you! 

You can use our Exact Forms Plus add-on with the new Quickbase Document Templates to create your document and store it directly in a file attachment field...
For NO additional costs.

You don't have to be an existing Exact Forms Plus client either!

We'll be hosting a webinar after next week's EmpowerPro event...keep an eye out for the registration link.

Interested? Contact support@juicedtech.com for more info!

Keith


Forum|alt.badge.img+1

Hey Rick, 

 

Hopefully you can help me. I keep getting an error on the post request. "This field contains invalid jinja references".

 

These are my references in my post request. Similar to what you posted earlier. I just can't sort out what the problem is. Is it reference directly from the url of get request or does something need to be in the body?

 

"28": {

 

"value": {

 

"fileName": "{{b.json.fileName}}",

 

"data": "{{b.json.data}}"

}

}

 

Here is my get request url.

 

https://api.quickbase.com/v1/docTemplates/1/generate?tableId=table ID&recordId={{a.id}}&filename=Major Offense Log - {{a.date|date_mdy}}&format=docx&margin=1 1 1 1&unit=in&pageSize=Letter&orientation=portrait&realm=info 


Top Step
Forum|alt.badge.img+12
  • Observing
  • Nov 28, 2026 4:49 PM UTC

Coming back to this one because there’s a native way to do it now. Per Quickbase's release notes, the Quickbase channel in Pipelines got a Generate Document step in October 2025, so the API request workaround above, which was the way to do it at the time, isn’t needed anymore.

The pipeline is three steps:

  1. A trigger on your table, like Record Created, Record Updated, or a checkbox users tick when they want the PDF.
  2. Quickbase > Generate Document. Pick the table and template, map the Record ID# from the trigger, and choose PDF or Word.
  3. Quickbase > Upload a File. Point it at the same record and your file attachment field, and map the file URL from the Generate Document step.

Edwin, this should also get you past the jinja error, since there's no JSON body to build by hand.

Document templates and the Generate Document step need the Business or Enterprise plan.

https://resources.quickbase.com/nav/app/bu9ax9c5r/table/bu9a2h65e/action/dr?rid=140&ifv=1