Hello everyone -- I have an issue that some folks may know how to solve:
How to use a hidden value to perform a calculation when inside a
repeating group? I get an error when I try to do this.
Here is the story:
I have a form in commcare that is repeating questions for each member of a
household that is being surveyed.
Therefore, first I asked “what is the total number of people in the
household,” stored in a question keyword number_in_house.
Then I made a repeat group titled repeatgroup ... which repeats
number_in_house times.
One of the questions in the repeat group is date of birth, titled dob.
Then, I made a hidden value, simply to calculate the age... call the field
calculate_age ... of course, something like
int((today()-/data/repeatgroup/dob) div 365.25)
And then, for this example, let’s say that for now I just output that
calculated value using a label.
But when I do this, of course, I get an error message... internal error
handling request... a lot of tech stuff, then says type mismatch, and
something was not found. NOTE: I am attaching a screenshot with the error.
What is the technique to make this calculation work inside a repeat group?
I overheard someone say that there were a few lines of custom XML?
Thanks so much for any help!
Eric
Eric,
I'd recommend checking out the thread here:
https://groups.google.com/forum/#!msg/commcare-users/rxvCL0X7uBI/xi-ZZSXJ5kQJ
In particular, notice the line:
This <setvalue event="jr-insert" ... /> will fire every time a new repeat
begins and should be what you're looking for.
Best,
Will
···
On Thu, Jun 5, 2014 at 12:38 AM, Eric Stephan wrote:
Hello everyone -- I have an issue that some folks may know how to solve:
How to use a hidden value to perform a calculation when inside a
repeating group? I get an error when I try to do this.
Here is the story:
I have a form in commcare that is repeating questions for each member of a
household that is being surveyed.
Therefore, first I asked “what is the total number of people in the
household,” stored in a question keyword number_in_house.
Then I made a repeat group titled repeatgroup ... which repeats
number_in_house times.
One of the questions in the repeat group is date of birth, titled dob.
Then, I made a hidden value, simply to calculate the age... call the field
calculate_age ... of course, something like
int((today()-/data/repeatgroup/dob) div 365.25)
And then, for this example, let’s say that for now I just output that
calculated value using a label.
But when I do this, of course, I get an error message... internal error
handling request... a lot of tech stuff, then says type mismatch, and
something was not found. NOTE: I am attaching a screenshot with the error.
What is the technique to make this calculation work inside a repeat
group? I overheard someone say that there were a few lines of custom XML?
Thanks so much for any help!
Eric
--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.