Answered

Is there a way to add a custom parameter (e.g. code) in a question?

  • 22 February 2022
  • 2 replies
  • 961 views

Userlevel 1

So when user finishes the form, we get a payload like this 

{
"event_id": "",
"event_type": "form_response",
"form_response": {
"form_id": "",
"token": "",
"landed_at": "",
"submitted_at": "",
"hidden": {
"email": "",
"uuid": ""
},
"definition": {
"id": "",
"title": "User Sign-Up",
"fields": [
{
"id": "",
"title": "Great, can we get your full name?",
"type": "short_text",
"ref": "",
"properties": {}
},
{
"id": "",
"title": "Company Type:",
"type": "multiple_choice",
"allow_other_choice": true,
"ref": "9aaaeeebe70858c4",
"properties": {},
"choices": [
{
"id": "XQFP1gfHQ6rM",
"label": "Startup"
},
{
"id": "KrJvEaAXRNCQ",
"label": "Devshop"
},
{
"id": "zjOVcAj5Ua13",
"label": "Enterprise"
},
{
"id": "pHtQgmfwF4Va",
"label": "Freelance"
}
]
},
{
"id": "",
"title": "Role:",
"type": "multiple_choice",
"allow_other_choice": true,
"ref": "7207397713e2b5e3",
"properties": {},
"choices": [
{
"id": "3VfNPhSjMeJW",
"label": "Product Designer"
},
{
"id": "p0jUbkKt4hgZ",
"label": "Developer"
},
{
"id": "NpGdcyLYS22o",
"label": "Product Manager"
},
{
"id": "LQdXhn16njKb",
"label": "Team Leader"
}
]
},
{
"id": "RgytThByK0yO",
"title": "Purpose of using Nest",
"type": "long_text",
"ref": "18842abd9aa9ded4",
"properties": {}
}
]
},
"answers": [
{
"type": "text",
"text": "",
"field": {
"id": "C0DME1QGAUxh",
"type": "short_text",
"ref": "ef34b985c51e4131"
}
},
{
"type": "choice",
"choice": {
"label": ""
},
"field": {
"id": "ZVZHdZ4pB4DJ",
"type": "multiple_choice",
"ref": "9aaaeeebe70858c4"
}
},
{
"type": "choice",
"choice": {
"label": ""
},
"field": {
"id": "NQYmmuE8TifK",
"type": "multiple_choice",
"ref": "7207397713e2b5e3"
}
},
{
"type": "text",
"text": "",
"field": {
"id": "RgytThByK0yO",
"type": "long_text",
"ref": "18842abd9aa9ded4"
}
}
]
}
}

Is there a way do add a variable on the question or the answer???

For example this is one of the questions
{
                    "id": "",
                    "title": "Great, can we get your full name?",
                    "type": "short_text",
                    "ref": "",
                    "properties": {}
}

and I want to do this:
{
          "id": "",
          "title": "Great, can we get your full name?",
          "type": "short_text",
          "ref": "",
          "properties": {}
          “code”:”user_full_name”
}

So it could be a bit easier for me to get the values and answer

icon

Best answer by mathio 22 February 2022, 21:54

View original

2 replies

Userlevel 7
Badge +5

Hello @AaronMendez15 

you can add custom variables to your typeform via hidden fields. You will pass the value in URL (as hash #name=value) or via attribute for embedded forms (data-tf-hidden=”name=value”). You can access value of hidden field for each response (see hidden object in example payload for Responses API).

If you want to use “code” to identify the question to further process it using custom script, you can use custom refs to label your questions.

Userlevel 7
Badge +5

Hi @AaronMendez15 Were you able to give this a try? Let us know how it went for you!

Reply