Repository mode builds a package in a separate repository table: a child table related to your master table. Each step in the sequence adds its document to that table as a new record, related to the master record. A PDF Merger step at the end then merges those records into one PDF. Repository mode is also the only mode that can add files that no extension generates, using Static Document and Dynamic Document steps.
Note
Repository mode is an advanced setup that you build by hand. The installation wizard doesn't create a repository table, doesn't add the repository parameters to the Package Builder fields, and doesn't offer Static Document or Dynamic Document in the Add-On field. Set up a package in regular mode first (see Set up a package), then use this article to switch it to repository mode.
When to use repository mode
Keep every document of the package. Each document is its own record in one table, so users can open, review, or download the parts as well as the merged PDF.
Add fixed files. Cover letters, terms and conditions, or a "This page intentionally left blank" page, added with a Static Document step.
Add files from the record. A signed agreement or a form a user uploaded to the master record, added with a Dynamic Document step.
Merge from one place, in order. Because every part of the package is in one table, a single PDF Merger query can collect them, sorted in the order they were added.
How repository mode works
Clear old records. Before the run, Package Builder deletes the repository records related to this master record, so the package starts empty. You can change or turn off this cleanup with rppurgemode and rpaqry. See Clearing old records.
Run each step in order. Package Builder runs the steps in the order of the Record ID#s in pckgsq, and waits for each one to finish before starting the next.
Exact Forms Plus, XL Docs, and PDF Stamper steps save their document to the repository table themselves, using repository options in their own arguments.
Static Document and Dynamic Document steps are handled by Package Builder: it copies the file and adds it to the repository table as a new record.
Merge. A PDF Merger step, normally the last one, finds the repository records for this master record, sorts them by Record ID#, and merges them into one PDF. The merged PDF goes wherever the PDF Merger arguments say, for example a file attachment field on the master record.
Set up the repository table
Create a table to hold the parts of each package, for example Package Documents, and relate it to your master table, so that one master record has many package documents. The table needs these fields:
Field | Type | Used for |
|---|---|---|
The reference field that relates the record to the master record, for example Related Project | Numeric (created by the relationship) | Required. Its field ID goes in rprelfid. Package Builder writes the master record's key into it for each file it adds, and uses it to find the records to delete before a run. |
A file attachment field, for example Document | File attachment | Required. Its field ID goes in rpfafid. Static Document and Dynamic Document files are saved here. Point the other steps' repository options at the same field, so the merge finds every part in one field. |
Record ID# | Built in | Records are added in run order, so sorting by Record ID# (field 3) puts the parts in package order for the merge. |
A checkbox, for example Keep | Checkbox | Optional. Lets users mark records that the cleanup before each run must not delete. Use it with rpaqry. |
To create the table:
In your app, create the table and add the file attachment field.
Create a relationship where one master record (for example one Project) has many repository records. Quickbase adds the reference field to the repository table.
Open the repository table's Fields settings and note the field IDs of the reference field and the file attachment field. Note the table alias too, for example [_DBID_PACKAGE_DOCUMENTS], and the table ID. See Find your Client ID, table IDs, and field IDs.
Repository mode parameters
Add these parameters to the two Package Builder fields on the master table: Process Package (Progress Bar) for runs from the button, and Package Builder Batch Arguments for runs in the background. In the button formula, each parameter starts with &; in the batch arguments, each starts with a space. The full list of Package Builder parameters is in Formula URL parameters.
Parameter | Description | Sample in Formula |
|---|---|---|
rpmode | Turns repository mode on. Use y or true (any case). Any other value, or leaving it out, runs the package in regular mode. | "&rpmode=y" |
rpdbid | Required in repository mode. The table ID of the repository table. Use the table alias. | "&rpdbid=" & [_DBID_PACKAGE_DOCUMENTS] |
rprelfid | Required in repository mode. The field ID of the reference field in the repository table that relates it to the master table. | "&rprelfid=6" |
rpfafid | Required in repository mode. The field ID of the file attachment field in the repository table. Static Document and Dynamic Document files are saved here. | "&rpfafid=7" |
rpkeyval | Optional. The master record's key value, written into rprelfid for each file Package Builder adds and used to find the records to delete. Defaults to the master record's Record ID# (msid). Use it only when the relationship uses a key field other than Record ID#. In the batch arguments, wrap the value in double quotes if it can contain spaces. | "&rpkeyval=" & [Project Number] |
rpaqry | Optional. An extra Quickbase query that limits which related records the cleanup deletes. Package Builder deletes only the related records that also match this query. In the button formula, don't use & inside the value. | "&rpaqry={'8'.EX.'0'}" |
rppurgemode | Optional. When to delete the existing repository records for this master record: before (the default), after, both, or any other value, such as none, to never delete them. See Clearing old records. | "&rppurgemode=before" |
If rpmode is on and rpdbid, rprelfid, or rpfafid is missing, nothing is built. From the button, the window shows The parameters are invalid. Please contact your app administrator.
Package Builder's own batch configuration, as the wizard creates it, checks only clientid and appid, so adding these parameters to Package Builder Batch Arguments doesn't need a change there. The steps' own configurations are different; see Each step's own batch configuration.
Clearing old records
Warning
By default, repository mode deletes records. Before each run, Package Builder deletes every record in the repository table that is related to the master record, including files that users added by hand and documents from earlier runs. Package Builder doesn't keep a copy of what it deletes. If the repository table holds anything you want to keep, set rpaqry to protect those records, or set rppurgemode=none, before you run the package.
Package Builder finds the records to delete with the query {'rprelfid'.EX.'rpkeyval'} (the master record's Record ID# if you don't set rpkeyval). When rpaqry is set, it's added with AND, so only related records that also match rpaqry are deleted.
rppurgemode | What happens | Use it when |
|---|---|---|
before (default; also used when you leave it out) | Related records are deleted before the first step runs. The repository table then holds only this run's documents. | Each run should rebuild the package from scratch. This is the usual choice. |
after | Related records are deleted after the last step, including the PDF Merger step, finishes. | The repository records are only a working area and the merged PDF is saved somewhere else, such as the master record. |
both | Related records are deleted before and after the run. | As after, and you also want to clear anything left over from an earlier run that stopped. |
Any other value, for example none | Nothing is deleted. Each run adds more records. | You keep a history of every run. Make sure the merge query selects only the current run's records. |
Static Document and Dynamic Document steps
These two step types add a file that no extension generates. They work only in repository mode. Don't put them in a package that runs in regular mode.
Add-On value | Adds | Set up the template record |
|---|---|---|
Static Document | The same file in every package, such as a cover letter, terms and conditions, or a blank separator page. | Attach the file to the template record's Template File field. Leave Arguments FID empty. |
Dynamic Document | A file that changes from record to record, such as a signed agreement uploaded to the master record. | Leave Template File empty. In Arguments FID, enter the field ID of the master-table field that holds the file: a file attachment field, or a field that holds the file's URL. |
To use them:
In the Document Templates table, open the settings of the Add-On field and add the choices Static Document and Dynamic Document. Type them exactly like this, with the same capitals; Package Builder matches the Add-On value exactly.
Add a template record for each file, choose the Add-On value, and set it up as in the table above.
Add the template's Record ID# to the master record's Package Builder Template Sequence at the position where the file belongs in the package.
When the step runs, Package Builder downloads the file and adds a new record to the repository table: the master record's key goes in rprelfid and the file goes in rpfafid. The file name starts with the file's position in the package. These file types keep their extension: .pdf, .doc, .docx, .xls, .xlsx, .jpg, .jpeg, .png, .gif, .bmp, .tif, and .tiff. If you plan to merge the package into one PDF, PDF files are the safest choice.
If the field for a Dynamic Document is empty on a record, the step fails. Mark the step as not required (add :u after its Record ID# in the sequence, or check Not Required in Package on the template) if the package should be built without it.
Where each step's output goes
Step | What it adds to the repository table | What you set up |
|---|---|---|
Exact Forms Plus, XL Docs, PDF Stamper | The document the extension creates, as a new record related to the master record. | In the step's own arguments field on the master table, use the extension's repository options to save to the repository table, its reference field, and its file attachment field, and allow those values in the extension's batch configuration. Package Builder runs the extension with those arguments as they are; it doesn't redirect the output. For XL Docs, see Output and storage. |
Static Document, Dynamic Document | The file, as a new record related to the master record. | The repository mode parameters above. Package Builder adds the record itself. |
PDF Merger | Nothing, normally. It reads the repository records and saves one merged PDF where its arguments say. | A PDF Merger arguments field on the master table that uses Merge using a Query on the repository table. See PDF Merger formula text field parameters. |
A few things to know:
Two different rpmode parameters. The extensions have their own repository parameters with similar names. XL Docs, for example, turns its repository output on with repository=y and has an rpmode of its own (a to add a record, u to update one), along with rpdbid, rpfid, and rpfafid. Package Builder's rpmode=y goes in the Package Builder fields; the extension's repository=y and rpmode=a go in that extension's arguments field. Use the extension's add option so each run adds a new record.
One run per step. In repository mode, each step runs its extension once, with the whole arguments field. Unlike regular mode, the field isn't split into lines.
Order. Steps run one at a time in sequence order, so their records are added in that order. Sort the merge by Record ID# (slist=3 in PDF Merger) to get the package order.
Merging. Add the PDF Merger step as the last template in the sequence, or set mergeargsfid to the PDF Merger arguments field so Package Builder adds a merge step at the end for you. See Merge a package into one PDF.
Each step's own batch configuration
Batch configuration checking is on for every account. Each step runs its extension in batch—from the button as well as in the background—so the extension checks the step's arguments against its own batch configuration:
Each step's arguments must include configid=<that extension's Config Key>.
The configurations that the Exact Forms Plus, XL Docs, and PDF Stamper wizards create allow, in rpdbid and rpfafid, only the repository table you chose in that wizard—or only an empty value if you didn't choose one. They allow only the wizard's own output field in faid.
So before you add repository options for a new repository table, such as Package Documents, add that table's ID to rpdbid and its file attachment field ID to rpfafid in that extension's configuration in the Batch Config Portal. Otherwise the step fails, or its document isn't created.
The configuration the PDF Merger wizard creates checks only clientid and appid, so the merge query below doesn't need a change there.
See Each step's own batch configuration, Create and manage batch configurations, and Use a configuration in batch runs.
Example: a project invoice package
Each project needs one PDF made of a cover letter, the invoice, and the signed contract, in that order. Users should also be able to open each part on its own.
Tables and fields
Projects (master table). Fields used: XL Docs Batch Processing Arguments (field 54, the invoice), Signed Contract (file attachment, field 60), PDF Merger Parameters (formula text, field 61), Project Package (file attachment, field 62, receives the merged PDF), Package Date (date/time, field 63), and the fields the installation wizard added.
Package Documents (repository table, alias [_DBID_PACKAGE_DOCUMENTS]). Fields: Related Project (reference field, field 6), Document (file attachment, field 7), Keep (checkbox, field 8).
Document Templates records
Record ID# | Name | Add-On | Arguments FID | Template File | Not Required in Package |
|---|---|---|---|---|---|
7 | Cover Letter | Static Document | (empty) | Cover Letter.pdf | Unchecked |
3 | Invoice | XL Docs | 54 | Invoice.xlsx | Unchecked |
8 | Signed Contract | Dynamic Document | 60 | (empty) | Checked |
9 | Package PDF Merge | PDF Merger | 61 | (empty) | Unchecked |
The project's Package Builder Template Sequence is 7.3.8.9. The signed contract is optional, so a project without one still gets a package.
Formulas
First, in the Batch Config Portal, open the XL Docs configuration whose key is in XL Docs Batch Processing Arguments, and add the Package Documents table ID to rpdbid and 7 to rpfafid.
Then, in XL Docs Batch Processing Arguments (field 54), keep the invoice's arguments, including its configid=, and add XL Docs's repository options so the invoice is saved as a new Package Documents record:
... // the invoice's existing XL Docs arguments, including configid=<your XL Docs Config Key>
& " docfmt=pdf"
& " repository=y" // XL Docs: save to a repository table
& " rpdbid=" & [_DBID_PACKAGE_DOCUMENTS]
& " rpfid=6" // Related Project
& " rpfafid=7" // Document
& " rpmode=a" // XL Docs: add a new recordIn PDF Merger Parameters (field 61), merge this project's Package Documents records, sorted by Record ID#, into Project Package on the project:
"clientid=Q1234" // your Client ID
& " appid=" & AppID()
& " dbid=" & [_DBID_PACKAGE_DOCUMENTS]
& " msqry={'6'.EX.'" & [Record ID#] & "'}"
& " clist=3.7"
& " slist=3"
& " mrgdbid=" & Dbid()
& " mrgrid=" & [Record ID#]
& " mrgfa=62"
& " mrgfn=Project_Package_" & [Record ID#]
& " mrgdte=63"
& " configid=<your PDF Merger Config Key>"
// keep any other parameters the PDF Merger installation wizard addedIn Process Package (Progress Bar), add these lines inside Base64Encode( ... ), after the pckgsq line:
& "&rpmode=y"
& "&rpdbid=" & [_DBID_PACKAGE_DOCUMENTS]
& "&rprelfid=6"
& "&rpfafid=7"
& "&rpaqry={'8'.EX.'0'}" // keep records with Keep checkedIn Package Builder Batch Arguments, add the same parameters, each starting with a space:
& " rpmode=y"
& " rpdbid=" & [_DBID_PACKAGE_DOCUMENTS]
& " rprelfid=6"
& " rpfafid=7"
& " rpaqry={'8'.EX.'0'}"What happens when it runs
Package Builder deletes the project's Package Documents records that don't have Keep checked.
Cover Letter (template 7): Package Builder copies Cover Letter.pdf into a new Package Documents record.
Invoice (template 3): XL Docs creates the invoice PDF and adds it as the next record.
Signed Contract (template 8): Package Builder copies the file in the project's Signed Contract field into the next record. If the field is empty, the step fails, and because it's not required, the run continues.
Package PDF Merge (template 9): PDF Merger merges the project's Package Documents records in Record ID# order and saves the merged PDF in the project's Project Package field.
Package Builder writes Process Successfully Completed on and the date and time to Package Builder Status. See Run details and status.
Afterwards, Package Documents holds these records for project 25:
Record ID# | Related Project | Document | Keep | Added by |
|---|---|---|---|---|
141 | 25 | Cover letter (PDF) | Unchecked | Static Document step |
142 | 25 | Invoice (PDF) | Unchecked | XL Docs step |
143 | 25 | Signed contract (PDF) | Unchecked | Dynamic Document step |
The next run of the package for project 25 deletes these three records first and adds new ones.