Form redirects and dynamic prefills

When a user enters data into a Baserow form, we have the ability to automatically redirect them to another URL. I would like to redirect them to the same form again, but with some data prefilled, where the prefilled data is based on the row they just entered.

A very simple example would be that I have a form where one of the fields is a country. Let’s say they select Italy. When they submit the form, I want to redirect them to the same form again with Italy defaulted in the country field.

I know we have the ability to use ?prefill_<field+name>=<value>, but I want my value to be filled dynamically from a response in the current form.

I’ve read through this great post and was even able to create a formula field that generates the exact URL I want to redirect to, but I don’t there’s a way for me to automatically redirect (from Baserow) to that URL I just built.

So ideally I could specify a redirect URL where the prefill <value> is from a field entered in my current form… something like this :point_down:t4:

Any tricks to redirect and prefill forms based on data just submitted?

Thanks!!

1 Like

Hello @michael :wave:

@Alex, could you please help? Is there any way to specify a dynamic redirect URL?

1 Like

I don’t think there is anything built into Baserow that would allow for that. But I haven’t been working on the database team for half a year now so I am not fully up to date on what’s currently possible.

@davide maybe you have an idea of what might be possible here?

1 Like

The example I gave above might not sound super useful to others so I’ll give a bit more detail!

We have some tables that are relational whereby there is a header (parent) record and multiple detail (child) records. Right now I have forms for both the header and detail records, but for every detail record I record I create, I have to manually select it’s parent. Normally each header will have several (10s, not 100s) of detail records.

The user’s typical flow will be…

  • Create 1 header record (Baserow redirects to the detail form)
  • Create 5-20 detail records (Baserow redirects back to the detail form)

For each one of those 5-20 detail records, the user has to manually select the header record from a dropdown to establish the relationship.

Perhaps there are also other / better solutions than dynamic prefills ¯_(ツ)_/¯ ?

Thanks!

Hello @michael ,

We are working on a template that demonstrates this issue. It should be published with the next Baserow version.

The template has a table Orders and a form view. It also has a table Oder details with a form view. Both form views are shared and accessible through a url.

After filling in the first form (creating an order), you are redirected to to the form of the order details with the following url: https://baserow.io/form/[slug_comes_here]?prefill_Order={row_id}&hide_Order

The result is that the number of the order is not shown in the detail form, but is is stored. The only condition is that the primary key field of the Order table is the id of the row.

After you have completed a detail record, you refresh the page to add another record.

I know that this is not the perfect scenario when it comes to UX, but it might work for your scenario.

Regards
Frederik

1 Like

Hi @michael,

What @frederikdc suggested should solve the issue. Here are the steps you need to follow for your example:

  1. Create a “Header” table with a formula field as the primary key, using the formula row_id().
  2. Create a “Detail” table and add a ‘Link to Table’ field to connect it with the “Header” table.
  3. Create a form view for the “Detail” table. Add the ‘Link to Table’ field to the “Header” form as required, along with any other fields you want to include in the form.
  4. Share the Detail form publicly, and copy the URL to your clipboard.
  5. Create a form view for the “Header” table. Add the ‘Link to Table’ field to the “Detail” table as not required, and include any other necessary fields.
  6. In the redirect URL field, use the format suggested by @frederikdc: https://baserow.io/form/[detail_slug_comes_here]?prefill_Header={row_id}&hide_Header
  7. Distribute the URL for the “Header” form to your users. You can also hide the detail field if you want adding a ?hide_Detail at the end of the Header URL.

If you follow these steps, the users will fill out the “Header” form first, and after submission, they’ll be redirected to the “Detail” form with the “Header” field pre-filled.

Hope this helps!

Davide

1 Like