User Guide
The QB Document Generator is a cloud service that enables users to create Microsoft Word (.docx) file templates which are then populated with QuickBase data to produce .pdf, .docx, .jpeg, or .png output files.
Table of Contents
- Required QuickBase Tables
- Authoring a Template Document
- Token Reference
- Subtable Configuration
- URL Parameter Reference
- Triggering Document Generation
- Field Type Support
- Images
- HTML Rich Text
- Barcodes
- Troubleshooting
1. Required QuickBase Tables
Two QB tables must be created inside the QB application. The FIDs shown below are the defaults the document generator expects. If your tables were created in a different order and have different FIDs, you can override each one with a URL parameter (see §5).
1a. Document Templates
Stores the Word template files.
| # | Required | Field Name | Type | Default FID | URL Param Override | Notes |
|---|---|---|---|---|---|---|
| 1 | Optional | Template Name | Text | 6 | — | Descriptive name |
| 2 | Optional | Description | Text | 7 | — | |
| 3 | Required | MS Word Template File | File Attachment | 8 | tpfilefid |
The .docx template file |
| 4 | Optional | Active | Checkbox | 9 | — | Status flag |
| 5 | Optional | No Data Message | Text | 10 | tpndmfid |
Shown in subtables when query returns 0 rows |
| 6 | Optional | Output Type | Text | 11 | — | |
| 7 | Optional | Related App | Text | 12 | — | |
| 8 | Required | Subtables DBID | Formula — Text | 13 | tpstdbfid |
Formula returning the DBID of your Document Subtables table |
Tip: Create fields in the order above and QB will assign FIDs sequentially — matching the defaults above, so no URL overrides are needed.
The No Data Message (default FID 10) is displayed in a subtable when the QB query returns zero rows. Leave blank to suppress the table entirely when empty.
The Subtables DBID field must be a Formula — Text field that evaluates to the DBID of your Document Subtables table. In QB, this is done with a table variable reference. Go to your Document Subtables table → Settings → Advanced to find its variable name, then enter a formula like:
[_DBID_DOCUMENT_SUBTABLES]
Replace DOCUMENT_SUBTABLES with whatever variable name QB assigned to your table. The variable name is shown in the table's Advanced Settings page.
1b. Document Subtables
Stores per-template subtable configurations (one record per subtable section).
| # | Required | Field Name | Type | Default FID | URL Param Override | Notes |
|---|---|---|---|---|---|---|
| 1 | Required | Settings | Multi-Line Text | 6 | stcfgfid |
The subtable config string (see §4) |
Tip: Create Settings as the first user-created field so QB assigns FID 6 automatically.
2. Authoring a Template Document
Create a standard .docx file in Word. Replace the data you want populated with tokens.
Token Overview
| Token | Purpose |
|---|---|
~FID~ |
Insert a field value from the master record |
~I:FID:SIZE~ |
Insert an image from the master record with explicit sizing |
~=barcode(f[FID],type,WxH)~ |
Render a barcode |
~strid=N~ |
Replace this paragraph with a subtable |
Example Template Snippet
Invoice #: ~6~ Date: ~8~
Bill To: ~45~
~strid=1~ ← this paragraph becomes the line-items table
Notes: ~92~
Uploading the Template
Attach the .docx file to the MS Word Template File field (default FID 8; override with tpfilefid if your table differs) of the corresponding record in your Document Templates table.
3. Token Reference
3a. Field Substitution — ~FID~
Replaces the token with the value of field FID from the master record.
~168~ → value of field 168
~45~ → value of field 45
- Multiple tokens can appear on the same line or in the same paragraph.
- If the value contains HTML (e.g. a QB rich-text field), it is converted to Word formatting automatically (see §9).
- If the field is a file attachment or contains an image URL, the image is embedded automatically (see §8).
3b. Sized Image — ~I:FID:SIZE~
Embeds an image from field FID at a specific size. The token must be the only content of its paragraph (on its own line). Case-insensitive (~i:~ and ~I:~ both work).
| Size Format | Meaning |
|---|---|
~I:23:100~ |
Width = 100 px; height proportional |
~I:23:100x50~ |
Exact 100 × 50 px (may distort) |
~I:23:25%~ |
25% of original dimensions |
~I:23:25%F~ |
Same as 25% ("fixed percent") |
3c. Barcode — ~=barcode(f[FID],type,WxH)~
Generates a barcode image from the value of field FID. See §10 for full details.
~=barcode(f[123],qrcode,60x60)~
~=barcode(f[123],code128-b,200x80)~
3d. Subtable — ~strid=N~
Replaces the entire paragraph with a formatted table built from a QB query. N is the Record ID of the configuration record in the Document Subtables table.
~strid=4~
- Must be the only content of its paragraph.
- The table is rendered using the column definitions, colors, and query in the subtable config (see §4).
4. Subtable Configuration
Each subtable is configured by a record in the Document Subtables table. The entire configuration lives in a single text string in the Settings field (default FID 6).
Settings String Format
~dbid=TABLE_DBID,qry={QUERY},hdr=#COLOR-COLOR,sub=#COLOR-#COLOR,align=ALIGN,slist=FID,clist=COLUMNS~
All parts are comma-separated key=value pairs. clist must always be last because column definitions can contain commas.
| Key | Required | Description |
|---|---|---|
dbid |
Yes | DBID of the table to query |
qry |
Yes | QB query string; use [Record ID#] as a placeholder for the master record ID |
hdr |
No | Header row colors: #RRGGBB-colorname (bg-text). Default: #808080-white |
sub |
No | Row colors: #RRGGBB-#RRGGBB (odd-even). Default: #FFFFFF-#FFFFFF |
align |
No | Table alignment: l, c, or r. Default: l |
slist |
No | Sort field ID |
clist |
Yes | Column definitions (see below) |
Query Placeholder
Use [Record ID#] anywhere in the qry string — it is replaced with the master record's ID at runtime:
qry={'165'.EX.[Record ID#]}AND{'655'.EX.'0'}
Column Definition Format (clist)
Columns are separated by . (dot). Each column follows one of two formats:
Standard column: [ALIGN][TYPE][FID]:[WIDTH_PX]:[HEADER]
Image column: [ALIGN]I[FID]:[SIZE]:[HEADER] (no colon between I and FID)
| Part | Values | Description |
|---|---|---|
ALIGN |
L R C |
Left, Right, Center |
TYPE |
(blank or T) |
Plain text |
$ |
Currency — formats as $1,234.56 |
|
I |
Image column (file attachment or <img> HTML field) |
|
FID |
number | QB field ID |
WIDTH_PX |
number | Column width in pixels |
SIZE |
see below | For image columns: size specification |
HEADER |
text | Column header text |
Image column size formats:
| Format | Meaning |
|---|---|
200 |
Width = 200 px; height proportional |
100x50 |
Exact 100 × 50 px |
25% |
25% of original dimensions |
25%F |
Same as 25% |
Full Example
~dbid=bhkkqamev,qry={'165'.EX.[Record ID#]}AND{'655'.EX.'0'},hdr=#848484-white,sub=#FFFFFF-#F0F0F0,align=c,slist=314,clist=LT14:70:ITEM.CT124:200:DESCRIPTION.RF18:70:QTY.CN1245:70:UNITS.R$787:70:PRICE.R$24:70:AMOUNT~
Broken down:
| Column Spec | Align | Type | FID | Width | Header |
|---|---|---|---|---|---|
LT14:70:ITEM |
Left | Text | 14 | 70 px | ITEM |
CT124:200:DESCRIPTION |
Center | Text | 124 | 200 px | DESCRIPTION |
RF18:70:QTY |
Right | Text | 18 | 70 px | QTY |
CN1245:70:UNITS |
Center | Text | 1245 | 70 px | UNITS |
R$787:70:PRICE |
Right | Currency | 787 | 70 px | PRICE |
R$24:70:AMOUNT |
Right | Currency | 24 | 70 px | AMOUNT |
No-Data Message
When a subtable query returns zero rows, the document generator displays a single merged-cell row with the text from the No Data Message field (default FID 10) of the template record. If that field is blank, the table is omitted entirely.
5. URL Parameter Reference
Core Parameters
| Parameter | Required | Description |
|---|---|---|
clientid |
Yes | Key in the QB_CLIENTS KV store; identifies the QB app credentials |
tpdbid |
Yes | DBID of the Document Templates table |
tpid |
Yes | Record ID of the template to use |
msdb |
Yes | DBID of the source (master) table |
msid |
Yes | Record ID of the source record |
faid |
Yes | Field ID on msdb where the generated file is uploaded |
fn |
No | Output filename without extension (default: document) |
docfmt |
No | Output format: docx (default), pdf, jpeg, or png |
efpdte |
No | Field ID on msdb to stamp with the generation timestamp (ms since epoch) |
stream |
No | y — also stream the file back as a browser download |
addfiles |
No | Dot-separated file refs to append after the generated document (PDF/image only) |
prefiles |
No | Dot-separated file refs to prepend before the generated document (PDF/image only) |
preqbaction |
No | URL to fire before generation (fire-and-forget) |
appid |
No | Ignored; accepted for URL compatibility |
FID Override Parameters
Use these when your Document Templates or Document Subtables table has different field IDs than the defaults. All are optional — omit them if your tables use the standard field layout from §1.
| Parameter | Default | Overrides |
|---|---|---|
tpfilefid |
8 |
FID of the DOCX file attachment in the Document Templates table |
tpndmfid |
10 |
FID of the No Data Message in the Document Templates table |
tpstdbfid |
13 |
FID of the Subtables DBID formula in the Document Templates table |
stcfgfid |
6 |
FID of the Settings string in the Document Subtables table |
6. Triggering Document Generation
Add a Formula — URL field to your source table. When clicked, it calls the document generator.
Minimal Formula (DOCX output)
"https://gen.baseforbusinessutilities.com/doc_generator"
& "?clientid=my-client-id"
& "&tpdbid=TEMPLATES_TABLE_DBID"
& "&tpid=TEMPLATE_RECORD_ID"
& "&msdb=" & Dbid()
& "&msid=" & [Record ID#]
& "&faid=OUTPUT_FIELD_ID"
& "&fn=" & URLEncode([Invoice #])
& "&docfmt=docx"
PDF Output
& "&docfmt=pdf"
Image Output (JPEG or PNG)
& "&docfmt=jpeg"
& "&docfmt=png"
Single-page documents return the image file directly, uploaded to QB as a .jpg or .png.
Multi-page documents return a .zip archive containing one image per page, named sequentially:
page-0001.jpg
page-0002.jpg
page-0003.jpg
...
The document generator detects single vs. multi-page automatically — your formula URL does not need to change. The file extension is set based on the output.
When addfiles or prefiles is used with an image format, the referenced PDFs are merged before rasterisation so the final ZIP (or single image) covers all pages from all merged documents.
Append or Prepend Existing PDF Files
Use addfiles and/or prefiles to merge one or more existing QB file attachment PDFs around the generated document before it is uploaded. Works with pdf and image output formats.
Each parameter is a dot-separated list of file references. Three reference formats are supported:
| Format | Example | Description |
|---|---|---|
| Field ID | 227 |
File attached to that field on the master record |
| Cross-table ref | dbid:rid:fid |
File in another table (DBID, record ID, field ID) |
| Indirect ref | FID123 |
Value of field 123 is itself a dbid:rid:fid pointer |
& "&prefiles=227" ← prepend field 227 attachment
& "&addfiles=228" ← append field 228 attachment
& "&addfiles=227.bu5h2c6bg:42:15" ← field 227 + a cross-table ref
Stamp a "Last Generated" Field
& "&efpdte=DATETIME_FIELD_ID"
Stream File to Browser (in addition to QB upload)
& "&stream=y"
Fire a Pre-Generation Action
Executes a URL (fire-and-forget) before the document is built — useful for triggering a QB action or webhook:
& "&preqbaction=" & URLEncode("https://yourcompany.quickbase.com/db/TABLE?a=API_EditRecord&...")
7. Field Type Support
The following QuickBase field types are handled automatically when used with ~FID~ tokens:
| QB Field Type | Rendering |
|---|---|
| Text | Plain text insertion |
| Multi-Line Text | Plain text; <BR> tags converted to line breaks |
| Rich Text / Formula returning HTML | Full HTML-to-Word conversion (see §9) |
| Numeric | Raw value |
| Currency | Formatted as $1,234.56 |
| Date | Formatted as MM-DD-YYYY |
| Date/Time (Timestamp) | Formatted as MM-DD-YYYY |
| Checkbox | true / false |
| File Attachment — image | Image embedded inline (see §8) |
| File Attachment — non-image | Silently suppressed (raw filename/URL is never shown) |
Formula — Text returning <img> HTML |
Image embedded inline (see §8) |
| Formula — URL | Plain URL text |
| Formula — any other | Treated as text |
8. Images
8a. Master Record — Auto-Embed (~FID~)
If a field's value is a file attachment or an HTML <img> tag, the image is automatically embedded when you use a plain ~FID~ token on its own paragraph line. The image is scaled to fill the full content width.
~227~ ← if field 227 is a file attachment or <img> HTML, renders as an image
8b. Master Record — Explicit Size (~I:FID:SIZE~)
Use this token when you need precise control over image dimensions. Place it alone on its own paragraph line:
~I:227:300~ width = 300 px, height proportional
~I:227:300x200~ exactly 300 × 200 px
~I:227:50%~ 50% of original size
8c. Subtable Image Columns
Use I as the type character in a clist column definition. The document generator tries the QB REST API first (file attachment fields), then falls back to extracting a URL from the field value (formula fields returning <img> HTML):
CI2688:200:PHOTO center-aligned, FID 2688, 200 px wide, header "PHOTO"
CI2688:100x50:PHOTO exact 100 × 50 px
LI2688:25%:PHOTO left-aligned, 25% of original size
8d. Subtable Auto-Image (HTML Fields)
Any subtable text column whose field value is an <img src="URL"> HTML tag will automatically render the image — no special column type needed. The image is scaled to the column width.
This is useful for formula fields that generate barcode <img> tags or reference external image URLs.
Supported Image Formats
PNG, JPEG, GIF, WebP
9. HTML Rich Text
When a ~FID~ token's value is HTML, it is converted to Word formatting automatically.
Supported HTML Elements
| HTML | Word Output |
|---|---|
<b>, <strong> |
Bold |
<i>, <em> |
Italic |
<u> |
Underline |
<br>, <BR/> |
Line break |
<p>, <div> |
Paragraph |
<h1> – <h6> |
Headings (bold, sized) |
<ul>, <ol>, <li> |
Bullet / numbered lists |
<hr> |
Horizontal rule |
<table>, <tr>, <td>, <th> |
Embedded table |
<img src="..."> |
Embedded image |
<span style="color:..."> |
Inline text color |
<font color="..."> |
Inline text color |
Block vs Inline
- Block HTML (paragraphs, tables, lists): replaces the entire containing paragraph.
- Inline HTML (bold, italic, spans, line breaks): substituted within the existing run.
The document generator detects which case applies automatically based on the HTML content.
Example: QB Formula Returning a Table
A QB formula field can produce an HTML table:
<table>
<tr><th>Tier</th><th>Price</th></tr>
<tr><td>1–10 units</td><td>$5.00</td></tr>
<tr><td>11–50 units</td><td>$4.50</td></tr>
</table>
When this field is referenced via ~FID~ on its own paragraph line, the entire HTML table is converted to a Word table and inserted into the document.
10. Barcodes
Use the barcode token to generate and embed a barcode image from a field value.
Token Syntax
~=barcode(f[FID],type,WxH)~
| Part | Description |
|---|---|
FID |
Field ID whose value becomes the barcode data |
type |
Barcode symbology (see table below) |
W |
Output image width in pixels |
H |
Output image height in pixels |
The token is case-insensitive.
Text Display Suffix (Linear Barcodes Only)
Append a suffix to type to control human-readable text below or above the bars:
| Suffix | Effect |
|---|---|
| (none) | Hide text entirely |
-b |
Show text below the bars |
-t |
Show text above the bars |
~=barcode(f[123],code128,200x80)~ no text
~=barcode(f[123],code128-b,200x80)~ text below
~=barcode(f[123],code39-t,150x60)~ text above
Supported Symbologies
type |
Symbology | Dimension |
|---|---|---|
qrcode |
QR Code | 2D |
datamatrix |
Data Matrix | 2D |
pdf417 |
PDF417 | 2D |
code128 |
Code 128 (auto) | Linear |
code128a |
Code 128A | Linear |
code128b |
Code 128B | Linear |
code39 |
Code 39 | Linear |
code39extended |
Code 39 Extended | Linear |
code93 |
Code 93 | Linear |
code93extended |
Code 93 Extended | Linear |
code11 |
Code 11 | Linear |
codabar |
Codabar | Linear |
code32 |
Code 32 | Linear |
ean8 |
EAN-8 | Linear |
ean13 |
EAN-13 | Linear |
Examples
~=barcode(f[56],qrcode,80x80)~
~=barcode(f[78],ean13,200x80)~
~=barcode(f[101],code128-b,250x100)~
Barcodes are generated at runtime via barcode.tec-it.com and embedded as GIF images.
11. Troubleshooting
"No file found at Document Templates record…"
The template record exists but has no .docx file attached to the MS Word Template File field. Upload a .docx to that field. If your table's file attachment field has a FID other than the default (8), specify it in the URL using tpfilefid=YOUR_FID.
Token not replaced (still shows ~168~ in output)
- Confirm the FID is correct — check the field in QB (Admin > Fields).
- The field may not be in the master table (
msdb). Each token references a field on the master record, not related tables. - The field value might be empty. An empty field replaces the token with an empty string — the token itself will not appear in the output.
Subtable is missing / not rendered
- Confirm
~strid=N~is on its own paragraph line in the template (no other text in that paragraph). - Confirm the Record ID
Nexists in the Document Subtables table. - Check the
dbidin the settings string — it must match the table you're querying. - Confirm the Subtables DBID formula field on the template record returns the correct DBID.
Image shows "Picture can't be displayed"
- Confirm the image field contains a valid file attachment or a valid
<img src="URL">value. - For external image URLs, confirm the URL is publicly accessible (no authentication required).
- For QB-hosted images, confirm the app credentials configured for this client have read access to the source table and record.
Currency fields show raw numbers
Currency formatting is applied automatically when the QB field type is Currency. If the field is a Formula returning a number, it will not be formatted as currency. Change the field type to Currency in QB, or use a $ type column in the subtable clist (e.g. R$24:70:AMOUNT).
Date shows as a raw number (milliseconds)
The field type in QB must be Date or Date/Time. Formula fields returning a date-like number are not automatically formatted. Use a proper Date field in QB.
Barcode renders as empty or missing
- Confirm the field value is non-empty for the master record being generated.
- Check that the barcode type and data are compatible (e.g. EAN-13 requires exactly 12 or 13 digits).
- The barcode service (barcode.tec-it.com) is a public API — confirm it is reachable from your network if testing locally. It is always reachable during cloud generation.