Dynamically add options to a Multichoice via JS | XM Community
Skip to main content
Question

Dynamically add options to a Multichoice via JS

  • 20 June 2024
  • 3 replies
  • 39 views

Hello to everyone.

I’m working on a feedback survey for internal IS services. The survey is integrate with ServiceNow that is passing closed ticket data like short description, ticket number etc. through embedded data.

In the survey there’s a multiple choice that should be populated with these data, the Short description for the text and the ticket number for the value. 

I wrote some Javascript but I got stuck here because I have no idea on how to add the options.

    var ticket0desc = Qualtrics.SurveyEngine.getJSEmbeddedData('ticket_0_shortdesc');
var ticket0number = Qualtrics.SurveyEngine.getJSEmbeddedData('ticket_0_number');

var container = Qualtrics.SurveyEngine.getInstance(this.questionId).getQuestionContainer();

Maybe the multiple choice it’s not the best option, any suggestion is welcomed :)

Thanks in adavance.

3 replies

Badge +1

The best way would be to use piped text.

Make sure your embedded data elements are set before the question in the survey flow, and then you should see the option when editing your answers choices. 

 

It will look like that : ${e://Field/ticket_0_shortdesc}

 

Here is the link for more info about piped text: https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/piped-text/piped-text-overview/

Badge +1

@xpoulin Thanks for the suggestion I did it and it works.

I have another issue now: The multiple choice has a a display logic associated to it because I need to show it only when a customer select that they want give feedback on tickets. The integration with SNOW can pass up to 20 tickets but usually these could be less. In this case I would need to put a display logic on the single choice but this is not possible if I have a display logic on the Multiple choice. 

I could use JS but I would prefer not if it’s possible. 

Badge +1

I see that the problem it’s not the display logic on the question but the in page display option. I think that if I want to keep the in page display effect I need to use some JS.

Leave a Reply