Saving data to a ledger: Setting up transaction questions

Saving data to a ledger: Setting up transaction questions

Why?

  • This will allow you to create or update your ledger quantities.

  • Used inside a repeat group, you can iterate over your product list and update for example the stock values.

How?

  • Question ID: whatever you want

  • Source/Destination case: this is the id of the case of the ledger or entity id.

    • If you want to apply the transaction to a ledger of the current case use: instance('commcaresession')/session/data/case_id

    • For supply chain, if you want to use the supply-point case of the user: instance('commcaresession')/session/user/data/commtrack-supply-point

    • If you want to select the select supply point case (see here), use: instance('commcaresession')/session/data/case_id_case_supply-point

    • Any case id can be used here. 

  • Balance ID: This is the name of the ledger. The default should be “stock” but you can create any id you want.

  • Product: current()/../../../@id (3 dots)

  •  

    • This exact text should be used for a transfer inside a group.

    • If the transfer question is in a group in the repeat add one set of double dots and use: current()/../../../../@id

  • Quantity: value to set the ledger quantity with. It can reference a question in the repeat where you ask about, or calculate quantity. Normal calculates work fine here.