# Update a case property when case is selected from a multiple choice list

**URL:** <https://forum.dimagi.com/t/update-a-case-property-when-case-is-selected-from-a-multiple-choice-list/3692>\
**Category:** Users\
**Created:** [September 4, 2017, 1:58pm UTC](https://forum.dimagi.com/t/update-a-case-property-when-case-is-selected-from-a-multiple-choice-list/3692 "2017-09-04T13:58:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ameera\_Hamid](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@Ameera\_Hamid](https://forum.dimagi.com/u/Ameera_Hamid)\
**Post date:** [September 4, 2017, 1:58pm UTC](https://forum.dimagi.com/t/update-a-case-property-when-case-is-selected-from-a-multiple-choice-list/3692/1 "2017-09-04T13:58:05Z")

</div>

Hi,

I am working on an attendance app. The app has two types of modules; one  
that enrolls the student and another that records the class attendance.

In the class attendance module there is an attendance form that makes use  
of a multiple choice checkbox with parent cases (from the enrolment module)  
as list options. the teacher is then expected to select from the list  
those students who are absent. In the parent case, there is a property  
called days absent (calculate condition set to 0) - I want to be to +1 and  
update that case property every time the teacher selects the student in the  
child form from the multiple choice list with cases. Is this possible? and  
if so how do i go about doing this?

Secondly, when setting up the multiple choice checklist with cases the  
value is set to @case\_id and the label set to case\_name. Is it possible to  
set the value to a case property like student\_gender so that we are able to  
count the number of girls absent and the number of boys absent when the  
teacher completes the attendance register form with that multiple choice  
case list question?

Kindly,  
Ameera

---

<div class="post-metadata">

**Author:** ![Clayton\_Sims](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/clayton_sims/32/496_2.png) [@Clayton\_Sims](https://forum.dimagi.com/u/Clayton_Sims)\
**Post date:** [October 3, 2017, 10:58pm UTC](https://forum.dimagi.com/t/update-a-case-property-when-case-is-selected-from-a-multiple-choice-list/3692/2 "2017-10-03T22:58:47Z")

</div>

Hi Ameera,

For your first query on marking the attendance per-case:  
Unfortunately, the mechanism you'd need to use to update each case  
individually isn't really possible to configure in CommCare HQ.

For your second query:

I'm assuming you followed this pattern:  
[https://confluence.dimagi.com/display/commcarepublic/Multiple+Choice+Questions+with+Cases+as+Choices](https://confluence.dimagi.com/display/commcarepublic/Multiple+Choice+Questions+with+Cases+as+Choices)

to create your form.

There is a way for you to determine the # of boys and # of girls who are  
absent.

At the end of following that instruction set, you would have had a "case  
query" expression that looked like

instance('casedb')/casedb/case[@case\_type='your\_type'][index/parent =  
instance('commcaresession')/session/data/case\_id]

I'll be assuming that your select question has the ID children\_in\_attendance

If you make a hidden value in the form you can copy and paste the text you  
entered to the "_Query Expression_" box of the checkboxes question, and  
then at the _end_ you can add the following "filter"

[not(selected(#form/children\_in\_attendance, @case\_id))]

which will filter all of the children who _were_ chosen (which would mean  
that the remaining children were displayed but not selected.

After that you can add a filter for the child's gender

[not(selected(#form/children\_in\_attendance, @case\_id))][gender='male']

and then put all of that in a _count()_

so the final hidden value calculation would look like

count(instance('casedb')/casedb/case[@case\_type='your\_type'][index/parent =  
instance('commcaresession')/session/data/case\_id][not(selected(#form/children\_in\_attendance,  
@case\_id))][gender='male'])

-Clayton

> **···**
>
> On Mon, Sep 4, 2017 at 9:58 AM, Ameera Hamid wrote:
> 
> > Hi,
> > 
> > I am working on an attendance app. The app has two types of modules; one  
> > that enrolls the student and another that records the class attendance.
> > 
> > In the class attendance module there is an attendance form that makes use  
> > of a multiple choice checkbox with parent cases (from the enrolment module)  
> > as list options. the teacher is then expected to select from the list  
> > those students who are absent. In the parent case, there is a property  
> > called days absent (calculate condition set to 0) - I want to be to +1 and  
> > update that case property every time the teacher selects the student in the  
> > child form from the multiple choice list with cases. Is this possible? and  
> > if so how do i go about doing this?
> > 
> > Secondly, when setting up the multiple choice checklist with cases the  
> > value is set to @case\_id and the label set to case\_name. Is it possible to  
> > set the value to a case property like student\_gender so that we are able to  
> > count the number of girls absent and the number of boys absent when the  
> > teacher completes the attendance register form with that multiple choice  
> > case list question?
> > 
> > Kindly,  
> > Ameera
> > 
> > --  
> > 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](mailto:commcare-users+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Toby](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@Toby](https://forum.dimagi.com/u/Toby)\
**Post date:** [January 29, 2022, 8:54pm UTC](https://forum.dimagi.com/t/update-a-case-property-when-case-is-selected-from-a-multiple-choice-list/3692/3 "2022-01-29T20:54:26Z")

</div>

Hi Clayton,

Is there any update or workaround on the first part of this question, about updating a case after multichoice selection?

Thanks  
Toby
