Hi!
I’m creating a dynamic data attachment of a form to itself. (e.g., the form is both the parent and the child form).
Inside the form, I’m collecting 30 integers.
When I open up the form a second time, I’m then going to check each integer entered against all integers entered previously in all 30 fields.
For example, if I’m entering an integer, I want to check that it doesn’t match an integer from any of the 30 fields in any previous submission.
This could get very tedious in the programming of the XLSForm, as for each of the 30 integers, I’d need to check against 30 values (would that be 900 lines of code?)
So instead, what I’m trying to do is to create a little ‘repeat loop’ that dynamically checks the integer entered against all 30 fields.
I’ve used ‘concat’ to create the calculation string needed for the dynamic data attachment calculation, but I essentially then need the ‘string’ created in each repeat loop to be turned into a dynamic formula.
So, say I have my calculated string as something like this (forgive the weird formatting, as this is needed to prevent errors in the concat function): concat(“count(instance('xlsfo”, “rm’)/root/data[group/”,${dynamic_name}," = cur", “rent(”, “)/.”, “./label_id_1])”)
Then, I want to have a ‘calculate’ question that actually calculates this formula in repeat loop #1:
count(instance(‘xlsform’)/root/data[group/label_id_1 = current()/…/label_id_1])
And it would calculate this formula in repeat loop #2:
count(instance(‘xlsform’)/root/data[group/label_id_2 = current()/…/label_id_1])
etc, etc.
However, when I put a calculate question in the repeat loop, I just put ${dynamic_formula} in the calculation column, but instead of evaluating the string as a formula, it just places the string as the value of that field.
So it doesn’t allow me to creata a dynamic formula.
Any idea how to create a dynamic formula?
Thanks!
Janna