
Solved
setChoiceValueByVariableName: what to use as variableName parameter?
I wish to use the setChoiceValueByVariableName API function with a question of type Text Entry - Form variant.
This function should be called as `setChoiceValueByVariableName(variableName, [subId], value)` where `variableName` is a string described as "The variable name of the choice(s) being set" in the documentation.
In the SE engine, I used to replace `variableName` with the text that appears on the left of the text field in the form.
With the new JFE engine, these lines of code no longer work (no error message, the text fields are simply no longer populated).
Does anyone know what the variableName parameter should contain when using this API function?
this.setChoiceValueByVariableName("byVariableName", "Modified answer"); // Does not work
this.setChoiceValue(2, "Modified answer"); // Works
Results in:
!

Best answer by fleb
> @GhisLabo said:
> Piped text is not appropriate in my case because the question is inside a Loop & Merge block. The same variable gets reused several times within a survey run.
Generally, this does not matter. The embedded fields are updated after each loop. Therefore you can use piped containing an embedded field. It will always contain the information generated in the previous loop. Here you can find how to set any text (including the piped one) as a default choice in the text entry box.
I have tried following simple code and it worked.
Qualtrics.SurveyEngine.addOnload(function()
{
var questionText = "${lm://Field/1}";
var n = "${e://Field/n}"+ questionText;
Qualtrics.SurveyEngine.setEmbeddedData("n", n);
});
In case this won't help you to solve your problem, I recommend you to
> clarify a bit more what it is exactly you are trying to accomplish
as @RDurant said.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
