# Loading Case ID into Form

**URL:** <https://forum.dimagi.com/t/loading-case-id-into-form/2724>\
**Category:** Users\
**Created:** [May 10, 2016, 12:17pm UTC](https://forum.dimagi.com/t/loading-case-id-into-form/2724 "2016-05-10T12:17:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lexa\_Koenig](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/l/ec9cab/32.png) [@Lexa\_Koenig](https://forum.dimagi.com/u/Lexa_Koenig)\
**Post date:** [May 10, 2016, 12:17pm UTC](https://forum.dimagi.com/t/loading-case-id-into-form/2724/1 "2016-05-10T12:17:18Z")

</div>

Hi CommCare Users,

I am designing a form in which I need to do two things:

1. Load the case\_id of a parent Case into a form
2. Load the case\_id of a case into a form

I am having trouble accessing the case property for Id. I've tried  
parent\_id, case\_id (I get the message that this is a reserved name),  
@case\_id, among others.

Has anyone had success in doing this previously? Can you share what the  
case property syntax is for getting the case\_id?

Thank you!  
Lexa

---

<div class="post-metadata">

**Author:** ![czue](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/czue/32/493_2.png) [@czue](https://forum.dimagi.com/u/czue)\
**Post date:** [May 10, 2016, 12:43pm UTC](https://forum.dimagi.com/t/loading-case-id-into-form/2724/2 "2016-05-10T12:43:51Z")

</div>

Hi Lexa,

I think there is an easier way to do this, but one thing you can do is use  
the following expression directly in a form/calculate expression:

instance('commcaresession')/session/data/case\_id

If you're using parent/child selection I think you should also be able to  
use this for the parent:

instance('commcaresession')/session/data/parent\_id

If you're not using parent/child selection I think you can use:

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

Again, I think there may be easier ways to do this, but I believe these  
should work.

Cory

> **···**
>
> On Tue, May 10, 2016 at 8:17 AM, wrote:
> 
> > Hi CommCare Users,
> > 
> > I am designing a form in which I need to do two things:
> > 
> > 1. Load the case\_id of a parent Case into a form
> > 2. Load the case\_id of a case into a form
> > 
> > I am having trouble accessing the case property for Id. I've tried  
> > parent\_id, case\_id (I get the message that this is a reserved name),  
> > @case\_id, among others.
> > 
> > Has anyone had success in doing this previously? Can you share what the  
> > case property syntax is for getting the case\_id?
> > 
> > Thank you!  
> > Lexa
> > 
> > --  
> > 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:** ![Lexa\_Koenig](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/l/ec9cab/32.png) [@Lexa\_Koenig](https://forum.dimagi.com/u/Lexa_Koenig)\
**Post date:** [May 10, 2016, 1:14pm UTC](https://forum.dimagi.com/t/loading-case-id-into-form/2724/3 "2016-05-10T13:14:11Z")

</div>

Hi Cory,

Thanks so much - this worked perfectly!

Lexa

> **···**
>
> On Tuesday, May 10, 2016 at 2:44:12 PM UTC+2, Cory Zue wrote: \> \> Hi Lexa, \> \> I think there is an easier way to do this, but one thing you can do is use \> the following expression directly in a form/calculate expression: \> \> instance('commcaresession')/session/data/case\_id \> \> If you're using parent/child selection I think you should also be able to \> use this for the parent: \> \> instance('commcaresession')/session/data/parent\_id \> \> If you're not using parent/child selection I think you can use: \> \> \> instance('casedb')/casedb/case[@case\_id=instance('commcaresession')/session/data/case\_id]/index/parent \> \> Again, I think there may be easier ways to do this, but I believe these \> should work. \> \> Cory \> \> \> On Tue, May 10, 2016 at 8:17 AM, \<le...@verasolutions.org \> wrote: \> \>\> Hi CommCare Users, \>\> \>\> I am designing a form in which I need to do two things: \>\> \>\> 1. Load the case\_id of a parent Case into a form \>\> 2. Load the case\_id of a case into a form \>\> \>\> I am having trouble accessing the case property for Id. I've tried \>\> parent\_id, case\_id (I get the message that this is a reserved name), \>\> @case\_id, among others. \>\> \>\> Has anyone had success in doing this previously? Can you share what the \>\> case property syntax is for getting the case\_id? \>\> \>\> Thank you! \>\> Lexa \>\> \>\> \>\> -- \>\> 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-user...@googlegroups.com . \>\> For more options, visit https://groups.google.com/d/optout. \>\> \> \>
