Stream: questionnaire
Topic: variable scope for populate
Diane (Jul 30 2021 at 04:13):
My questionnaire has one group containing Questions 1, 2, 3 and then one group containing Questions 4, 5, 6. I want to store the answer to Question 1 in a variable to use for expressions used to populate Questions 2, 3 from the 1st group and then Questions 4, 5 and 6 from the 2nd group. Where do I put the extension with the variable? I was thinking of putting it on the group item for the 1st group. But then, is it only in scope for the 1st group? Will the expressions in the 2nd group be able to access the variable declared in the 1st group? Should any variables go at the header level for the Questionnaire?
Lloyd McKenzie (Jul 30 2021 at 04:53):
A variable is only available to the item it's defined on and all descendants. If you have a variable that references content in group 1 and needs to be available to a sibling group, then the variable needs to be on the parent of both groups - which might be the Questionnaire as a whole.
Last updated: Apr 12 2022 at 19:14 UTC