If you send out surveys on a regular basis, e.g. for evaluations, sending forms with some pre-filled answers will help respondents complete them more quickly. Baserow Forms provide a solution for auto-filling responses.
Prefilling forms is an effective way to reduce workload and prompt people to act. Instead of sending blank forms, pre-filled forms automatically populate each field with their information. When a respondent clicks on a pre-filled form link, some of the answers are already populated. This eliminates the need to fill out each field individually.
This tutorial will cover how to share a Baserow form with information already prefilled inside the form.
Create an account or log in to your existing 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 database. A database is a collection of tables, each containing rows and columns.
For this tutorial, we will work with a simple data structure and create a database from a template. Add the User Feedback template to your workspace by clicking the ‘Use this template’ button:
The User Feedback database has three tables: Users, Feedback submissions and Features.
When a new row is created in the Feedback submissions table, we want to capture the ‘Submitted by’ data, using a Link to table field to reference the person who submitted it.
This table also has a feedback form view to receive feedback.
We already have a Feedback form view in the Feedback Submissions table. If you don’t have one in your table, you can create a new form view.
Forms can be automatically created from your database. You can easily build forms with click-to-add functionality from the Feedback form view sidebar.
After the form is set up, create a private shareable link to the form. Click on ‘Share form’ at the top of the screen and copy the generated URL to make this form 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.
We want to pre-fill the form with existing data via query parameters added 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 (&
).
Copy your share form URL
Append query params to the end of a URL, add a ‘?
’ followed immediately by a query parameter
Type prefill_
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.
After inputting the form field name, type the value that you would like the field to be prefilled with, starting with the =
equals sign: ?prefill_<field_name>=<value>
Encode query string parameter name and/or value for various symbols to avoid any issues with the query parameter.
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 calledfirst name
with the value ofMike 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>
. Separate multiple 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.
Do not prefill values that may violate privacy or compliance policies. The prefilled value will appear in the URL generated for the pre-filled form. When the form respondent clicks on the URL, the prefilled value will appear in their browser’s address bar. If they delete the encoded 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.
If you need to create many prefilled form URLs, doing that manually for each unique row is error-prone and can be quite tedious. By using Baserow’s formula field, you can 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 fields.
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 the 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:
Append the form URL with the user’s data using a CONCAT( )
function in the formula builder.
Reference the Feedback form formula field created, e.g. concat(field('Feedback form')
Input the name of the form field to be prefilled as shown in the form. This element will be static and thus wrapped inside quotations, e.g. '?prefill_Submitted+by='
Append the table field to be dynamically prefilled for each row to populate the user’s data, e.g. field('Name')
Combine the arguments with a ,
and ensure any special characters are URL encoded.
concat(field('Feedback form'),'?prefill_Submitted+by=',field('Name'))
To prefill more information about the respondent, add an ampersand between variables
Wrap the 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")
Copy and Share the pre-filled link.
When you access the URL created, it will prefill a form for the respondent.
If you run into an issue while following the tutorial, feel free to reach out to ask for help in the Baserow community.
What’s your use case? Tell us how you use Baserow
Today we are releasing Baserow 1.17 with huge performance improvements for high volumes of data, calendar view, ARM images & more…!