Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added a note about referencing the case id of a case in the form where that case is created (case_id_new_[casetype]_[n]

...

instance('casedb')/casedb/case[@case_type='commcare-user'][hq_user_id=instance('commcaresession')/session/context/userid]/@case_id


Session Data-- Referencing the Caseid inside Form Builder

...

In normal workflows you only select one case. In such settings the case_id can be accessed using the instance('commcaresession')/session/data/case_id path. If you're referencing the case id in a form that created the case, you have to reference it as instance('commcaresession')/session/data/case_id_new_[case_type]_[n]. N indicates where that case falls in the order of cases being created in that form (is 0-indexed). For example, if your form is just creating one case of the one client case type, this will be: instance('commcaresession')/session/data/case_id_new_client_0. However, if your form is creating multiple cases, that last number will increment. You can find out the exact syntax by looking at the suite file.

If you are in a more advanced workflow (via advanced modules) you will be prompted for the 'case tag' of the case being loaded on HQ. If you set the case tag to 'load_mother' for example, then in the CommCare session instance you can access that case's id using the path instance('commcaresession')/session/data/case_id_load_mother

...