Sending out surveys regularly? Pre-filling forms can help respondents complete them quickly. Baserow has a solution for auto-filling responses.
Pre-filled forms automatically populate each field with information, reducing workload and prompting action. When a respondent clicks on a pre-filled form link, some answers are already filled in, eliminating the need to fill out each field individually.
This tutorial will cover how to share a Baserow form with information prefilled.
Create or log in to your Baserow account.
The next step is to create a workspace. A workspace is a workspace where you can store multiple databases and invite collaborators.
Next, create a workspace to store multiple databases and invite collaborators.
Create a database, which consists of tables containing rows and columns.
For this tutorial, we’ll work with the User Feedback template. Add it to your workspace by clicking the ‘Use this template’ button.
The User Feedback database has three tables: Users, Feedback submissions, and Features. In the Feedback submissions table, we want to capture the ‘Submitted by’ data using a Link to table
field.
This table also has a Feedback form view to receive feedback.
If you don’t have a Feedback form view in your table, create one.
Forms can be automatically created from your database. Build forms easily with click-to-add functionality from the Feedback form view sidebar.
After setting up the form, create a private shareable link to make it public.
The form URL is pre-generated by Baserow. Once you get the form URL, you can add parameters in the form URL to prefill fields.
To pre-fill the form with existing data, add query parameters to the share form URL.
Prefill query parameters are prefixed with prefill
to avoid any collision with potential future query parameters. URL parameters are made up of a key (<field_name>
) and a value (<value>
), separated by an equal sign (=
). Multiple parameters are each then separated by an ampersand (&
).
?
’ followed immediately by a query parameterprefill_
and the name of the form field you wish to prefill. The part after prefill_
must exactly match the field name as it appears in the form.=
equals sign: ?prefill_<field_name>=<value>
Spaces in the field name are replaced with +, while Spaces in a pre-filled answer are replaced with %20. E.g. ?prefill_first+name=Mike%20Smith will prefill a field called first name with the value of Mike Smith. Note that the values are case-sensitive.
e. To prefill more form fields, enter an ampersand (&
) and then enter more prefill_ parameters in the format: ?prefill_<field_name>=<value>&prefill_<field_name>=<value>
. Separate multiple select fields with a ,
comma between the values.
You can prefill a field that you do not want the respondent to edit, such as user data, internal ID or a support ticket number. We may not want to give them that access to view or edit all other table data. An alternative would be to prefill the field with the data and then hide that field.
To hide a field dynamically, you can do so via query parameters added to the public from the URL. The query parameter is prefixed with hide_
encoded URL parameter to avoid collision with potential future query parameters.
<https://baserow.io/form/Be_3bysp4BkzhyinMEpKchhWJVCpPpPH2XH4HNvVudQ?prefill_Submitted+by=Carmelo%20Aguilar&hide_Submitted+by>
This formula hides each of the prefilled fields selected. The hidden form field will not be shown to the respondent. However, the prefilled value will still be entered into the row when the form is submitted.
Don’t prefill values that violate privacy or compliance policies. The prefilled value appears in the URL and the respondent’s browser’s address bar. If the respondent deletes the econded URL components from the address bar, the hidden form fields will appear in the form.
Next, let’s populate the form with existing data from your table using these URL parameters and the formula field.
Creating many prefilled form URLs manually for each unique row is error-prone and tedious. Use Baserow’s formula field to automatically prefill form URLs for new rows.
Create a formula field in the Users table and join multiple strings together as a single piece of text. This way the dynamic form URL can be linked to the row.
In the formula builder, add the generated share URL from the feedback form with quotes around it: '<form-URL'
Every row will be populated with a pre-filled link.
Generally, the prefilled value is the same as the value of the field. But there are some exceptions where the value is translated to a different value. Special field types are: Link to table, Single select, Multiple select, Rating, and Date.
In this tutorial, we will pre-fill the Feedback form with the user’s name—a Link to table field. A link to table field can accept the value that is shown in the select dropdown.
Create a new formula field to append query parameters to the form’s URL.
The formula will be dynamically set up based on the form and table so that every new row has a unique prefilled form:
concat( )
function in the formula builder.concat(field('Feedback form')
'?prefill_Submitted+by='
field('Name')
,
and ensure any special characters are URL encoded.concat(field('Feedback form'),'?prefill_Submitted+by=',field('Name'))
concat()
function with the replace()
function. This is because we want any spaces in the formula to be replaced with the + character so that the outputted URL is properly encoded.replace(concat(field('Feedback form'),'?prefill_Submitted+by=',field('Name'),'&hide_Submitted+by'), " ", "%20")
When accessed, the URL will prefill the form for the respondent.
If you need help prefilling forms, or simply want to share how you use Baserow, join us in the Baserow community!
What’s your use case? Tell us how you use Baserow