How to assign a Ref to a multiple choice answer | Community
Skip to main content
Answered

How to assign a Ref to a multiple choice answer


I’m using the API to pull responses, and I need to do conditional logic based on what the user chose on a multiple choice question.

I know I can assign a ref to the question, but is there a way to do this per answer?  I can get the ID of the choice, but that can change easily.

I get JSON like this:
 

{"type": "choice",

  "field": {

  "id": "5IyPfSq7OZNG",

  "ref": "my-question-1,

  "type": "multiple_choice"

  },

  "choice": {

    "id": "A3uXK14qAEPj",

    "label": "<<some label>>"

  }

}

I want something like:

{"type": "choice",

  "field": {

  "id": "5IyPfSq7OZNG",

  "ref": "my-question-1,

  "type": "multiple_choice"

  },

  "choice": {

    “ref”: “my-choice-a”

    "id": "A3uXK14qAEPj",

    "label": "<<some label>>"

  }

}

Best answer by Lasse

Hi Richard,

Lasse from Typeform Support here.

Thanks for the good question. I’m afraid, that at the moment it is not possible to use custom “refs” for “choices” in multiple choice questions.

This is a feature improvement request, and at the moment I cannot guarantee if or when it will be implemented. However, if it does get implemented we will update this thread accordingly:-)

The ID of the choice should not change, unless you make changes to the choices or the question. 

As you already shared in your post you can see both the question title + question ref and the choice ID and Label when you use our Retrieve-responses API, so I hope that you for now can use these to double-check that the answers you compare are the same when you apply your logic and conditions. 

Apologies for the limitation this time!

All the best,

View original

11 replies

Lasse
Typeform
Forum|alt.badge.img+1
  • Typeform
  • 13 replies
  • Answer
  • May 6, 2021

Hi Richard,

Lasse from Typeform Support here.

Thanks for the good question. I’m afraid, that at the moment it is not possible to use custom “refs” for “choices” in multiple choice questions.

This is a feature improvement request, and at the moment I cannot guarantee if or when it will be implemented. However, if it does get implemented we will update this thread accordingly:-)

The ID of the choice should not change, unless you make changes to the choices or the question. 

As you already shared in your post you can see both the question title + question ref and the choice ID and Label when you use our Retrieve-responses API, so I hope that you for now can use these to double-check that the answers you compare are the same when you apply your logic and conditions. 

Apologies for the limitation this time!

All the best,


  • Navigating the Land
  • 1 reply
  • January 17, 2022

Hii @Lasse 

I’m a little confused by this. 

On one hand, it seems like the Create API has the option to use readable refs

      "properties": {
        "allow_multiple_selection": false,
        "allow_other_choice": true,
        "choices": [
          {
            "label": "Foo",
            "ref": "foo_choice_ref"
          },
          {
            "label": "Bar",
            "ref": "bar_choice_ref"
          }
        ],
        "description": "Cool description for the multiple choice",
        "randomize": true,
        "vertical_alignment": false
      },
      "ref": "nice_readable_multiple_choice_reference",
      "title": "Multiple Choice Title",
      "type": "multiple_choice",
      "validations": {
        "required": false
      }
    },

But on the other hand, there doesn’t seem like a way to see these refs within the actual response api. 

Similarly, each choice has an ID in the question, but none in the answer choices (in an allow multiple selection), so it adds a level of complexity to figure out what even the ID of the answer choice is.

        "answers": [
          {
            "choice": {
              "label": "New York"
            },

Am I missing something? Is it impossible to get an actual usable reference of some sort for the answers besides the label?

 

Thank you,

Ezra


Lasse
Typeform
Forum|alt.badge.img+1
  • Typeform
  • 13 replies
  • January 19, 2022

HI @richard m  and @EzraButler 

Thank you both for bringing up this issue. 

I’m happy to inform you that our developers have now made the needed changes, and the Response API now includes the Ref for a multiple choice answers. 

I just made a test on one of my forms by:
 

I hope the above helps with your use cases

Good luck with your forms.


  • Navigating the Land
  • 1 reply
  • February 21, 2022

Hi @Lasse,

I’m using custom multi-choice refs, and I can see them when fetching responses via the API, which is great. But they don’t seem to be included in the response webhook payload. Are there plans to include them in that payload as well? At the moment, I think we’ll have to just use the webhook to trigger a REST API call back to typeform in order to get all the refs, which should work but it isn’t ideal.


  • Explorer
  • 2 replies
  • June 27, 2022

Hi, I was able to select some multiple choice by their ref codes. Actually the “other” option, as it has no ref it cannot be pre selected. Is there a way to trigger “other” to be preselected?


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14884 replies
  • July 25, 2023

  • Navigating the Land
  • 2 replies
  • May 2, 2024
Lasse wrote:

HI @richard m  and @EzraButler 

Thank you both for bringing up this issue. 

I’m happy to inform you that our developers have now made the needed changes, and the Response API now includes the Ref for a multiple choice answers. 

I just made a test on one of my forms by:
 

I hope the above helps with your use cases

Good luck with your forms.

@Lasse Thanks! Is it possible within the UI to edit answer `ref`s with custom values? We want to empower our non-technical team to set these values.


  • Navigating the Land
  • 2 replies
  • May 6, 2024

Hi @Liz - I just wanted to tag you in for my question above as it seems you might be the most active in these forums. Thanks!


Lasse
Typeform
Forum|alt.badge.img+1
  • Typeform
  • 13 replies
  • May 6, 2024

Hi, @joematune 👋 
Thanks for the question, and sorry for the slow response time. 

I can see it would be useful for your non-technical team to be able. set these values inside the UI/Form builder, but I’m afraid this is still not possible at this time. 

I will make sure to pass this on as a feature request with our Product Team, so they can consider this for future improvements. 


  • Navigating the Land
  • 1 reply
  • May 29, 2024

Agreed with @joematune.

It would be really useful to be able to set the `ref` for choices via the UI.

We are using Logic right now to set variables based on user choices, and that works fine for a question with a few options. For questions with a lot of choices, countries for example, it’s a bit tedious.

 


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14884 replies
  • May 30, 2024

Hi @prerak thank you for sharing that context - I’ll pass it along to the product team! 


Reply