I'm getting the following error, and I know where it's coming from but I'm unsure of how to resolve it while also continuing to use the functionality I want:
Display Condition Error: Error in calculation for /data/discharge_medications_group/discharge_medications_other/display Unable to evaluate
position
on /data/discharge_medications_group[1]/discharge_medications_other[1], which is empty.
My app has a checkbox question, discharge_medication and if the user selects the option 'Other' an integer question is displayed asking how many other medications the patient is taking. This integer serves as the repeat count for the repeat group (discharge_medications_other) collecting additional information for each discharge medication. Per app building best practices I added a Group inside the repeat group ( 'display') with the display condition position(..) < #form/discharge_medication_other_quantity. This works to allow the user to change the integer value to something smaller, but if the user selects the option 'Other' in the checkbox question, enters an integer value, and then de-selects the option 'Other' in the checkbox question I get the above error. This is also true if the user deletes the integer value they entered before de-selecting the option 'Other'.
How can I prevent this error from occurring while also ensuring that if the user changes the integer value entered to a smaller number the correct amount of repeat groups will appear?
Best Answer
You shouldn't use display conditions on repeat groups. Rather, you can remove the selected(question, 'other') display condition from the repeat group and put it on the folder within the repeat group along with the "position(..) < #form/.....)" display condition.