Skip to main content
Question

Document Template Save PDF to field in Record API Pipeline

  • Mar 13, 2025 11:11 PM UTC
  • 3 replies
  • 275 views

Forum|alt.badge.img+6

I have been wracking my head all day on this.  I was reading Generate Documents from your records in your app where it says "However, you can also create API calls and use Pipelines, code pages, or custom integrations to generate documents. Each part of the formula represents an API parameter.".  I was using Restful "Generate a Document" and was able to make a request:

How do I get the output of making a request or basically the document template for this record as a file attachment in the record?  I tried using:

<qdbapi>

<rid>1700</rid>

<field fid="22" filename="Model_T.jpg"> Base64 encoded file content</field>

 

Thank you so much!

3 replies

Forum|alt.badge.img+6
  • Author
  • Registered
  • Mar 13, 2025 11:12 PM UTC

Here is the below image as well hope that helps:

 


JimHarrison
Forum|alt.badge.img+18
  • Qrew Cadet
  • Jun 13, 2025 8:52 PM UTC

In the Print formula the var can look like any of these:

var text fileName = [Override Template Name];

https://api.quickbase.com/v1/docTemplates/1/generate?&tableId=bkp8cwnzs&realm=hardermech.quickbase.com&format=pdf&pageSize=Letter&margin=0.25%200.25%200.25%200.25&unit=in&orientation=portrait&recordId=3364&filename=512604-19254.Oregon.Summit

var text fileName = ""&[Override Template Name]&""; (this is not needed but it works)

https://api.quickbase.com/v1/docTemplates/1/generate?&tableId=bkp8cwnzs&realm=hardermech.quickbase.com&format=pdf&pageSize=Letter&margin=0.25%200.25%200.25%200.25&unit=in&orientation=portrait&recordId=3364&filename=512604-19254.Oregon.Summit

var text fileName = ""& URLEncode([Override Template Name])&"";

https://api.quickbase.com/v1/docTemplates/1/generate?&tableId=bkp8cwnzs&realm=hardermech.quickbase.com&format=pdf&pageSize=Letter&margin=0.25%200.25%200.25%200.25&unit=in&orientation=portrait&recordId=3364&filename=512604-19254.Oregon.Summit%20Contracting%20LLC

Also update the var text url line to look like this: (look, the filename is at the end)

var text url = "https://api.quickbase.com/v1/docTemplates/1/generate?&tableId=" & $tableId & "&realm=" & $qbRealm &"&format=" & $format &"&pageSize=Letter&margin=" & $margin &"&unit=in&orientation=portrait&recordId=" & ToText([Record ID#])&"&filename=" & $fileName;


Top Step
Forum|alt.badge.img+9
  • Registered
  • Oct 30, 2026 1:18 AM UTC

You’re close. The Generate a document call can return the file as JSON instead of a download, and a second request saves it into your file attachment field.

In Pipelines I use two Quickbase Make Request steps. The first is a GET to:

https://api.quickbase.com/v1/docTemplates/1/generate?tableId=YOUR_TABLE_ID&recordId={{a.id}}&filename=Document.pdf&format=pdf

That comes back with fileName and data, where data is the base64 PDF.

The second is a POST to https://api.quickbase.com/v1/records with this body, using your table ID and 22 as your file field:

{"to": "YOUR_TABLE_ID", "data": [{"3": {"value": {{a.id}}}, "22": {"value": {"fileName": "{{b.json.fileName}}", "data": "{{b.json.data}}"}}}], "mergeFieldId": 3}

Merging on Record ID# updates the same record instead of creating a new one. The XML upload you tried can work too, but the JSON body lines up with the generate response with nothing to convert.

https://developer.quickbase.com/operation/generateDocument 

https://developer.quickbase.com/operation/upsert