How to reference child element for computation on JSON Form?

On a modal with JSON form to create an Expense with Expense Lines (invoice line). On the line I want user to fill in Quantity and Price Unit, and the Sub Total is computed.

In the second picture, you can see that I try to compute the Sub Total,

{{formData.invoice_line_ids[0].quantity * formData.invoice_line_ids[0].price_unit}}

But because, I am using index = 0, this works only for the 1st line and won’t work for 2nd line.

How can I write the code to dynamically reference the child element to achieve the computation on 2nd line?

Hey @kittiu, you can directly use the sourceData property from the JSON form without pointing to a particular index to compute data dynamically.

Can you please give it a try?

Thanks for reply,

Nop, it not work. Because I am working on child object.

Hey this looks like an enhancement as there’s no way to reference the current array item directly. I will create an issue and share it with you.

1 Like