Sum of items

Actually I use Bonita Studio Community 7.5.4


I have created a form where I have a collection with a field called subtotal, therefore for each new collection another subtotal field is added so that they can be from 1 to 10,100 or 1000.


How can I add up all the subtotals that are generated?

I think the best way to do this is in a script because I need the total value to meet a condition on a gateway or if it is possible to do it from the form, could you give me ideas on how to do it!

Thanks in advanced!