SUM of Sub Repeating Group write to data field

Ok, I’ve spent too much time on this, I must be thinking about it wrong.


To help understand. I have a data type of LineItem. In that LineItem I have a YES/NO for isParent.
Each LineItem has a list of sub-lineitems and every line item has a “Sub-Total” field and a “Total” field.
I want to have the :sum of the sub items “Sub-Total” field to be written to the parents “Total” + the Parents “Sub-Total” field. Which I can do as a text field in my repeating group but how can I get that figure to write to the database field?

I’m trying to get the result that I’m getting in [Text Input ZZZZ] to write to the parents “Total” field.

What do your workflows for creating LineItems & SubLineItems look like? Seems that you could just update the “Total” field whenever a sublineitem gets created or updated:

  1. Create new LineItem:
    isPartent = No
    Subtotal = 100
    partent lineitem = (insert parent lineitem)
    etc.
  2. Make changes to (result of step 1’s lineitem’s parent lineitem)
    Total = (calculate total)