What is the syntax to reference form data in a model iteration query

commcare

Per this answer: Is it possible to use a repeat group to iterate over a space-separated list?
one can reference user input to control a model iteration.
That being the case, if my question ID is spaced_list then what should be the syntax in the three windows of a model iteration form interface:

  • Query Expression
  • Instance ID
  • Instance URI

I've tried using

  • 'instance('commcaresession')/session/data/spaced_list
  • commcaresession
  • jr://instance/commcaresession

but for some reason it automatically replaces "commcaresession" with "commcaression-1"

Best Answer

So the key thing with model iteration is that the model to iterate over has to be set when the form is opened. You cannot use any questions internal to the form in an iteration expression. You could still probably iterate over a space-separated list loaded from a case property.

Either way, it might make more sense to just use a regular repeat group without model iteration. You can make the repeat count equal to the number of words in your space-separated list and then load the n-th word into each repeat.