Loading Case ID into Form

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

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.
For more options, visit https://groups.google.com/d/optout.

1 Like

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. >> > >