How to check if a previous text entry matches any of the choices in the current question | XM Community
Skip to main content
Solved

How to check if a previous text entry matches any of the choices in the current question

  • October 7, 2020
  • 1 reply
  • 43 views

Forum|alt.badge.img+6

I am still new to this platform and this might be a simple solution.
I have a question that asks for the Canadian FSA which is the first 3 characters of the postal code (e.g. M5G)
My next question tracks if the FSA is on the list. If it's not on the list, terminate. So I created a single select hidden question that contains all the valid FSAs. What I want to do is to punch the FSA from the previous question here and then later on do a SelectedChoiceCount to check if FSA is valid.
So far I added this code but the valid FSA does not get selected.
var FSA = "${q://QID58/ChoiceTextEntryValue}";
this.setChoiceValue(FSA,true);

Can someone tell me why this code is not working?


Best answer by rarcega

Found the solution.
this.setChoiceValueByVariableName(FSA,true);

1 reply

Forum|alt.badge.img+6
  • Author
  • Level 2 ●●
  • Answer
  • October 8, 2020

Found the solution.
this.setChoiceValueByVariableName(FSA,true);