Pre-populate form fields to eliminate having to fill out the same information twice for your form submitters. This is a go-to with use cases like:
- Copying contact information from one form to another so that you can attribute a second form to the same person without them having to fill out all the information again.
- Sending out unique form URLs so that you can attribute a form to a certain club member.
- Creating a string of forms where different people fill out different sections.
Note - This process should only be used when looking to pass non sensitive information. PII and PHI data should not be passed via URL query string as it can leave the sensitive data exposed. Please refer to THIS guide if you need a breakdown on what is considered sensitive data. Also take a look at THIS guide that talks through how to properly set up your form to collect sensitive data and make sure you are not violating terms of service.
If you are looking for an easy way to pre-fill forms and create a secure end to end form based solution, check out our Workflows add-on. This can help take the guess work out of URL query string, secure the data being passed, and will allow you to easily blend our products together in a single flow.
Pre-populating form fields overview
To pre-populate form fields, take the URL for the form and add information to it. When the web page is loaded, the form will then also automatically load information into certain fields.
Gather data for the URL
To assemble the URL, you will need the following information:
- URL of the form you want to pre-populate
- The field labels that you want to populate
- The information you want to populate the fields with
1. The URL of the form you want to populate
In order to find the URL to the form you want to populate, log into Formstack and open the Publish page of the form. Then copy the form URL.
2. The field labels that you want to populate
Decide which fields you would like to be populated on the form. Then copy the field labels into your word processor for assembly later. Any misspellings will cause the field to not populate.
In this example, the fields are: “Name2” and “Email2."
Any spaces in the field label should be replaced with an underscore; for example, “Your Email2” should be replaced with “Your_Email2” since web addresses are not allowed to have spaces in them.
3. The information that you want to populate the fields with
There are two different ways to get this information:
- If you know the exact information you want to populate
- If you want to fill the information from another form
If you know the exact information you want to populate like a field that you want to be the same for every submission or if you're sending out a person-specific URL, then type exactly what you would like to be filled in within your word processor document.
Like the field label, it’s important to type it as you want it and to replace any spaces with underscores.
For this example, we’ll call the answers: “Formstack Support” and “support@formstack.com”
If you want to fill the information from another form like if you are directing a person from one form to another and don't want them to have to fill out duplicate information or if you're creating a multi-stage form where different persons fill out different parts, then do the following:
Step 1: Go to the Form where you want the information to be pulled from.
Step 2: Copy the needed Field IDs. You can find the field ID, by selecting it in the Builder mode and copying the ID from the URL:
Assemble the URL
You may build your custom URL now that you have gathered the needed information.
Please note: If you'll be attempting to pass data that will likely contain spaces or line breaks (for example - Short or Long Answer fields, Checkbox, or Radio buttons), this will break the URLs we're about to construct. There's no way around this unfortunately as spaces will break any URL. We encourage you to only pre-populate form fields from a previous form only if they will not contain spaces. If you're building a pre-populated URL manually, you can use the "%20" character to be a space in your data.
The basics
You will use the options you found above and put them into your URL in the following sequence:
(Form URL)?(First Field Label)=(First Information to Fill or Merge Field)&(Next Field Label)=(Next Information to Fill or Merge Field)
For example
- If you know the information:
With the link completed, you can send it out to your submitters to use.
- If you are populating from another form:
There are 3 symbols that you will use to distinguish information:
- ? - goes in between the second form URL and the first field name from the second form that you are trying to populate. You will not use this symbol again
- = - goes in between each field name from the second form and the information you want to fill that field in with (whether you type it manually or want to use info from another form). You will use this for each field that you want to pre-populate
- & - goes in between each of the field info and the next field name that you want to populate. You will use this for every set of fields that you want to populate
After you have the link finished, you need to decide how best to use it, which will depend on your situation. There are a few options:
- You can add the link to a Confirmation Email within the custom message
- You can add the link to a Notification Email within a custom message
- You can display the link on a Submit Action Thank You Page
- You can redirect the user to that link as a Submit Action
What if I don’t want my submitters to know this is happening?
You can easily mark any of these fields hidden so that your submitters don’t even see the fields that you are populating. For more information on how to do that, check out our Hidden Fields Support Doc
What if I don’t want my submitters to be able to edit the information?
You can easily mark any of these fields read-only so that, even if the submitter can see the field, they cannot edit it. For more information on how to do that, check out our Read-Only Fields Support Doc
Pre-populating field types
- Sub-fields populating
-
name field options include
- name
- name-first
- name-last
- date/time fields can have each part populated, also. As an example, we can populate that field to be January 10, 2014 PM as &datetime=January%2010%202014%
-
Address fields can be pre-populated as
- address-address
- address-address2
- address-city
- address-state
- address-zip
- address-country
- Multiple options on a checkbox field can be populated by separating each option with a new line, which is encoded in the URL string as "%0A” similar to the date
- If you are pre-populating a password-protected form, it’s important that you also include the password in the pre-populated URL so that the form can get past the password to populate the form.
- We do not currently support pre-populating embed forms
When you are done with the setup, distribute your custom URL, rather than the one under Publish, to have the information prefilled.