Lookup Table Data - Value Field

I would like to save the parent case ID for the case I am selecting in this lookup table question. I have tried using index and parent, but it has not worked, and it generates this error: "error".

What can I do?

I can help you with saving a parent case ID when using a lookup table question.

To reference a parent case ID in a lookup table question's value field, you need to use the correct syntax. The issue is likely with how you're referencing the parent case.

The correct approach:

In the Value field of your lookup table question, use:

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

Or if you want to reference the parent more directly:

instance('casedb')/casedb/case[@case_id = current()/../field_name]/index/parent

Where field_name is the name of the field where you're storing the selected case ID.

However, a few things to check:

  1. Does the case you're selecting actually have a parent case? Make sure the cases in your lookup table have a parent relationship defined (an index to another case).

  2. What is the exact index name? The index name might not be "parent" - it could be something specific to your case structure. Check your case structure to see what the index is actually called.

  3. Are you trying to save the parent of the selected case, or the parent of the current case? Make sure you're clear about which parent relationship you need.

Could you provide more details:

  • What type of cases are you selecting from in the lookup table?
  • Do those cases definitely have parent cases?
  • What is the parent relationship called in your case structure?

This will help me give you the exact syntax you need.

Since it is a “lookup table” question, I cannot use: instance('casedb')/casedb/case[@case_id = instance('commcaresession')/session/data/case_id]/index/parent

That expression is for hidden values. That is why, as shown in the image, it asks me to enter a value in the “Value Field”.

Currently, the expression in “Lookup Table” is:

instance('casedb')/casedb/case[@case_type = 'individuos'][@status = 'open'][num_ident_principal = current()/../../documento_participante]