How to set a default choice based on Variable Name? | Experience Community
Skip to main content
Solved

How to set a default choice based on Variable Name?

  • Dec 26, 2018 12:39 PM UTC
  • 4 replies
  • 122 views

Hi!!! Basically I want to set a default choice based on the answer given in the previous question and to do so I'm using the following JavaScript ! However, this is not working. Actually, it is setting the choice based on the recorde Value instead on the Variable Name. Can anyone help me out with this? Thanks

Best answer by PraDeepKotian_XM

Hello @filipe , Below is the code for setting the default choice based on the answer given in the previous question var val ="${q://QID30/ChoiceGroup/SelectedChoices}".split(", "); for (var i = 0; i < val.length; i++) { this.setChoiceValueByVariableName(val[i],true); }
View original

4 replies

Forum|alt.badge.img+19
  • Level 5 ●●●●●
  • Dec 26, 2018 2:12 PM UTC
You're pulling in the piping for the recode... did you try just ```${q://QID30/ChoiceGroup/SelectedChoices}```?

  • Author
  • Dec 26, 2018 3:21 PM UTC
> @Kate said: > You're pulling in the piping for the recode... did you try just ```${q://QID30/ChoiceGroup/SelectedChoices}```? Thanks for your reply Kate. It doesn't work. I did that and it doesnt set any default choice. As I have it now, it sets a default choice based on the Recorde Value. But what I want is based on the Variable Naming The "Variable Naming" of this question: ! should match the variable name of this question: !

PraDeepKotian_XM
QPN Level 5 ●●●●●
Forum|alt.badge.img+21
  • QPN Level 5 ●●●●●
  • Answer
  • Dec 27, 2018 3:05 AM UTC
Hello @filipe , Below is the code for setting the default choice based on the answer given in the previous question var val ="${q://QID30/ChoiceGroup/SelectedChoices}".split(", "); for (var i = 0; i < val.length; i++) { this.setChoiceValueByVariableName(val[i],true); }

  • Author
  • Dec 31, 2018 4:15 PM UTC
Thanks for the answer @PraDeepKotian_Ugam but is not working :(