← All help topics

TwinaForms Help

Prefill — load Salesforce data into the form.

Prefill runs queries against Salesforce before the user sees the form, then maps the results into fields. You drive it from URL parameters (like an email address), from values already in the form, or from the result of an earlier prefill query.

How it works

When a user opens a published form URL, TwinaForms runs all prefill actions server-side before rendering the form. Each action queries Salesforce based on a condition you define, stores the result under a name you choose (the alias), and then maps fields from that result into form elements.

A typical example: you email a customer a link like https://your-form.twinaforms.com/case-update?caseId=500XX0000000ABC. A prefill action reads {params.caseId}, queries the Case, and populates the form's Subject and Description so the customer just needs to add their reply.

Build a prefill action

Open the Prefill Actions tab inside the Designer and click + Add prefill action. You'll choose three things:

  1. Command — how Salesforce should be queried.
  2. Salesforce Object — what to query.
  3. Match conditions — how to find the right record(s).

Command types

  • Find one record (findOne) — query for a single record matching your conditions. Returns the first match, or nothing if there's no match.
  • Get by Id (getById) — read a single record directly by its Salesforce Id. Use this when you have the Id in a URL parameter.
  • Find multiple records (findMany) — query for a list. Used to populate a Records List (repeat group), or a picklist's options.

Match conditions

A condition compares a Salesforce field on the queried object to a value source. Each value source comes from somewhere:

  • URL Parameter — from the form URL's query string, e.g. ?email=user@example.com becomes {params.email}.
  • Form Field — the current value of another field on the form.
  • Literal Value — a fixed string or number you type in.
  • Alias Reference (Pro) — a field from a previous prefill action's result. Lets you chain queries together.

Operators include equals, not equals, contains, starts with, greater than, less than, is blank, and is not blank. Multiple conditions can be combined with AND / OR (multi-condition logic is a Pro capability).

The alias — "Store result as"

Every prefill action stores its result under a name you choose — the alias. The alias is how you reference the result later when you map it to form fields, or when you reference it from another prefill action.

For example, a prefill action that finds a Contact by email might use foundContact as its alias. Then on any form field, you can map a value from foundContact.FirstName, foundContact.Email, and so on.

Naming tip: use clear, intentional aliases like foundContact, caseRecord, or recentOrders. They'll appear in dropdowns when you set up field mapping, so a useful name saves time later.

Map prefill results to fields

Mapping happens on the field itself, not in the Prefill Actions tab. Select an input element on the canvas, then in the right-panel properties:

  1. Toggle Enable Prefill on.
  2. Choose the Prefill Alias from the dropdown (e.g. foundContact).
  3. Choose the Field Path on that result (e.g. Email or Account.Name).

The form will populate that field automatically when it loads. If you also turn on Locked field behavior, the field will be displayed as read-only when prefilled — useful for showing the user data you don't want them to edit.

See all mappings at a glance: the Prefill Actions tab's right panel shows a summary of every field that has prefill enabled, grouped by the action they reference. Useful for reviewing or cleaning up mappings without opening each field one by one.

Test with URL parameters

You can only test prefill on a published form — Draft versions don't run prefill. After publishing:

  1. Open the form's public URL.
  2. Append the parameters that your prefill actions need, e.g. ?email=test@example.com&source=newsletter.
  3. Open the URL in a browser. The form should render with values already filled in.

If something doesn't populate as expected, open the form's Submission Logs after a test submission. The log records which prefill matches happened, which were skipped, and any errors from Salesforce.

orderBy, limit, and "If no record found"

Three additional settings shape how a prefill behaves:

  • Order By (findMany only) — sort results by a field. Common choices are CreatedDate DESC for "most recent first" or Name ASC alphabetical.
  • Limit (findMany only) — the maximum number of records to return. Useful when you only want, say, the 10 most recent cases.
  • If no record found (findOne and getById) — Continue without prefill renders the form blank for that field, while Show error prevents the form from rendering and shows an error to the user. Default is "Continue without prefill".