Answered

How to add Hidden fields for an existing form using an API.

  • 9 March 2021
  • 9 replies
  • 609 views

If a form is already created using the Typeform portal and then I want to update the hidden fields for that form. How can we do that?

icon

Best answer by picsoung 20 March 2021, 00:39

View original

9 replies

Userlevel 7
Badge +5

Hi @ankit thanks for stopping by! If you want to update the hidden fields, you’ll want to use this call here. It’s important to note that it will update the entire form, as we don’t have a way yet to add just one field (or fields) without updating the entire form. You can see the PATCH option here. Hope that helps a bit!

Hi @Liz, I tried with the PATCH option but it is not working. It is saying “NOT_ALLOWED_VALUE”.

So means, every time we are creating a form, we need to pass the hidden field manually.

Userlevel 7
Badge +5

Hi @ankit the PATCH option won’t work for just adding hidden fields if you don’t include the entire form definition. This means that you’ll need to re-add each question in addition to adding the hidden fields. If that doesn’t work, would you mind sharing the call you’re making? 

Userlevel 7
Badge +5

Hey @ankit 

Are you creating forms via the APIs too? or manually in the builder?

If you do it via API, you can also specify hidden fields at the moment of creation under the hidden property.

"hidden": [
"user_id",
"email",
"another_hidden_field"
]


And via the builder, if your forms are similar, hidden fields should be copied when you duplicate a form.

If you want to change the value of a hidden field, so need to make an API call. Just change it’s value in the url

examples:
https://form.typeform.com/to/form1234#email=nico@lol.com
https://form.typeform.com/to/form1234#email=pedro@jojo.com

Hidden fields work as a “catch all”, we will grab the value passed in the url and store it with the answers submitted in the form.

Hi Picsoung,

We are creating the forms manually in the builder. We want to add new hidden fields via API, not to update the value.

Bumping this post, as adding hidden fields via the PATCH method is something I/my team would love to see support for as well. 

In fact, due to the automation tool we’re using and the fact that our users create forms via UI, it is the only way we can add our hidden fields to users’ typeforms

Any chance this will ever be addressed?

Userlevel 7
Badge +5

Hi @nelav 

Thank you for your feedback.

We haven’t planned to extend the possibility of the PATCH endpoint.

Which automation tool are you using at the moment?

You will need to first get the form
GET https://api.typeform.com/forms/form1234

Extract the JSON, change the properties as needed
And then upload the modified JSON using 

PUT https://form.typeform.com/to/form1234

Hope this makes sense

Thanks, I do understand it. Our team is using Make/Integromat, unfortunately it doesn’t support grabbing the full JSON body, only mapping specific properties. With an unknown # of form fields and nested values, this approach won’t work with the “grab everything and PUT” method, only with the targetted PATCH approach, unless I’m missing something.

Reply