I've seen the newly released feature "Forms" in Retool. Is prepopulating fields via URL parameters supported in this feature?
That is a good question. I need this feature,too.
Hi there,
Thanks for reaching out!
It looks like you can actually access the urlparams
of the form url inside of {{}}
like this:
Let us know if this doesn't solve your use case!
Working, Tess! Thank you! In case I chose a multi-select field. How does the URL param go?
You can define the param multiple times and it'll parse into an array.
?array=value1&array=value2&array=value3...
results in ["value1", "value2", "value3"]
Alternatively you can pass all of them as values with a separator in a single param and then split them into an array in the default value field.
Thanks @kschirrmacher, I am only trying to pass 1 parameter (even though this is multi-select cause it can happen) but this syntax didn't work.
https://yourURL#multi=Option%202
What worked for me is I added another instance of the field identifier at the end:
https://yourURL#multi=Option%202&multi
Ah yeah, since the multi-select expects an array and just a single instance of the parameter is just a string you need to convert that to an array.
Be careful passing an empty value like that though, as the underlying array is ['Option 2', null]
. If you insert or loop over multiselect.value
directly without dropping the nulls you'll end up with errors or empty values in places that you don't want them.
Example:
The cleaner method might be something like
Array.isArray(urlparams.multi) ? urlparams.multi : [urlparams.multi]