I have a module with “Household Registration” form and a “Woman registration” form. The case type of this module is - household. Then I have another module with case type- woman. I have a form in this module called “Woman close case” which is a subcase of the “Woman Registration” form and closes the case for the woman registration form.
I want to understand how case ids work in subcases. I noticed that for each household if I registered multiple women residing in that household all had same case Ids. Now in their respective closure forms the case Ids were different because of selecting a different case type.
I want to have the same case id for the woman registration form and its respective closure form. What is the best way to do it? And how do I assure that multiple women of the same households have different caseIds and still know for which household registration form it was filled by just matching the case ids.
Every case registered in CommCare has its own unique case_id, regardless of its parent/child status.
Since you mentioned seeing a difference in case_id between different forms, I suspect that you are either referencing the case_id within the form itself using something like
instance('commcaresession')/session/data/case_id, or that you are looking at form exports that include
form.case.@case_id. In either case, this can be explained by the structure of your app:
- Household Module
- Household Registration
- Woman Registration
- Woman Module
Since the “Woman Registration” form is in the Household Module, the default case_id property referenced by the form is that of the Household. To reference the Woman case’s case_id in the context of the Woman Registration form, you could use
instance('commcaresession')/session/case_id_new_child_0 within the form, or include
form.subcase_0.case.@case_id in the data export.
Note that, since Woman Close Case is in the Woman Module, the default case_id for this form is that of the Woman case.
Hope this is helpful! Let me know if you’d like me to clarify anything.
Thank you for your response. Yes, you are right I am using “form.case.@case_id” in form exports. I am not sure how to use “form.subcase_0.case.@case_id” in form export. Please guide me. Also, if you can suggest any pages for detailed reading on case id please send me the link. It will be very helpful.