Save documents to a repository table

Prev Next

By default, Exact Forms Plus saves each document to a file attachment field on the record it was created from. Instead, you can save documents to a repository table: a separate table, related to that table, whose records each hold one document.

A repository table is useful when:

  • a record has more than one document, for example a quote, an invoice, and a contract for the same project;

  • you want to keep every version of a document, not only the latest one;

  • you want one place for documents from several tables, and an embedded report of them on each record.

How it works

Each time the button runs, Exact Forms Plus:

  1. creates the document;

  2. adds a record to the repository table (or updates one, see New or update), and links it to the record the document was created from;

  3. saves the document in the repository record's file attachment field, and optionally copies values from the original record to it.

The original record isn't changed. Its EFP Document and EFP Date fields aren't updated, and the button's other update parameters (faid, efpdte, upmap, uid, clear, docsize) are ignored. To record details such as the date, copy them to the repository record instead (see Copy values to the repository record).

Set it up with the installation wizard

On the wizard's Exact Forms Plus setup step, select Use a Repository Table under Advanced Settings. The wizard then adds the Repository Table Setup step, where you choose or create the repository table and its file attachment field, and choose New or Update (see New or update). For every option on that step and what the wizard creates, see Repository table step. For the whole setup, see Set up Exact Forms Plus with the installation wizard.

The wizard adds the repository parameters to the buttons and to Batch Processing Arguments. To change them later, edit the button as described below.

Set it up in the button

To add a repository table to an existing button, or to change it, add these parameters to the button's formula:

Parameter

What it does

Example

repository

y saves to the repository table.

"&repository=y"

rpdbid

The repository table. Use its table alias. Required.

"&rpdbid=" & [_DBID_DOCUMENTS]

rpfid

The repository table's reference field to your table, for example Related Project.

"&rpfid=6"

rpfidval

The value to put in rpfid. Leave it out if your table's key field is Record ID#. Otherwise, pass the key field.

"&rpfidval=" & [Project Number]

rpfafid

The repository table's file attachment field for the document.

"&rpfafid=7"

rpmode

a adds a new record each time. u updates a record. Always set it: if you leave it out, Exact Forms Plus updates.

"&rpmode=a"

rpkfid, rpkval

With rpmode=u: a field in the repository table and the value it must have, to choose which related record to update.

"&rpkfid=9&rpkval=Quote"

rpmap

Copy values to the repository record. See Copy values.

"&rpmap=8:10|9:14"

rpuid

Set a user, email, or text field on the repository record to the person who selected the button.

"&rpuid=11:" & UserToEmail(User())

For example, inside the button's Base64Encode():

& "&repository=y"
& "&rpdbid=" & [_DBID_DOCUMENTS]
&"&rpfid=6"
& "&rpfafid=7"
& "&rpmode=a"

All parameters are described in Formula URL parameters.

New or update

Mode

What happens

New (rpmode=a)

Adds a repository record every time. Earlier documents stay as they are, so you keep a full history.

Update (rpmode=u)

Looks for repository records related to the original record (and, with rpkfid and rpkval, that also have that value). If it finds some, it updates the newest one. If it finds none, it adds a record.

Use Update when each record should have only one document of a kind, for example one current quote. To keep one record per document type, give the repository table a Document type field, set it with rpmap, and match on it with rpkfid and rpkval.

Copy values to the repository record

Use rpmap to copy values from the original record to the repository record: repository field:original field, with | between pairs. For example, rpmap=8:10|9:14 copies field 10 to repository field 8, and field 14 to repository field 9. Exact Forms Plus reads the original fields itself, so they don't have to be in the template's clist.

  • Don't map the fields in rpfid, rpfafid, or rpkfid.

  • To record when the document was created, use the repository table's Date Created field.

  • To record who created it, use rpuid. Exact Forms Plus runs as the user token saved for your account, so Record Owner and Last Modified By show that user, not the person who selected the button.

Save to Amazon S3 too

You can save each document to Amazon S3 and keep its S3 key on the repository record. Your account must be set up for Amazon S3 first.

With the installation wizard: choose Amazon S3 under Select a Cloud Storage Type as well as Use a Repository Table. The wizard then puts the S3 key and download fields on the repository table instead of your table. See What the wizard creates.

In the button: add amazons3=y and keyfid, the ID of a text field on the repository table:

& "&amazons3=y"
& "&keyfid=12"

On each run, Exact Forms Plus uploads the document to S3 and writes its key to keyfid on the repository record. The document is also saved in the repository record's file attachment field (rpfafid).

Make the S3 key different for each run. By default the key is the file name, the Record ID#, and the repository table's ID, for example Quote_12_bxxxxxxxx.pdf. That's the same every time the button runs for a record. With New, each run then replaces the previous file in S3, and all of the record's repository records point to the newest file. To keep every version in S3, set s3keyval to something that changes on every run, for example:

& "&s3keyval=Quote_" & [Record ID#] & "_" & ToText(ToTimestamp(Today(), ToTimeOfDay(Now())))

Or include the date and time in fn. See Formula URL parameters for s3keyval and s3bkt.

Dropbox and Egnyte work differently: the document is saved to Dropbox or Egnyte, but its file name or ID isn't written to the repository record. If you need a link to the cloud file on the record, use Amazon S3, or keep the file in Quickbase.

Things to know

  • Permissions. The user token saved for your account must be allowed to add and edit records in the repository table.

  • Merged documents (mrgdbid, mrgrid, mrgfa) are still saved to the record you name in those parameters, not to the repository table.

  • Mailing labels don't support repository tables. With repository=y, the labels aren't saved anywhere.

  • Values in the update search. If rpkval or the key value contains an apostrophe ('), the search can fail. Use values without apostrophes.

If something goes wrong

What you see

What to check

Exact Forms Plus Error: Input Parameters are Invalid. with repository and rpdbid listed

repository=y is set but rpdbid is missing.

A repository record is added, but it isn't linked to the original record

rpfid isn't the reference field, or the table's key isn't Record ID# and rpfidval is missing.

A record is updated when you expected a new one, or the other way round

Check rpmode. If it's missing, Exact Forms Plus updates. With u, check rpkfid and rpkval.

The repository record has no file

rpfafid is missing or isn't a file attachment field.

The S3 key isn't on the repository record

keyfid is missing, or is a field on your table instead of the repository table.

Older repository records open the newest document from S3

The S3 key is the same on every run. Make it unique with s3keyval (see Save to Amazon S3 too).

An error mentioning permissions or the user token

The token can't add or edit records in the repository table. See Troubleshooting.

The wizard shows a message on the Repository Table Setup step

See Repository table step messages.