I'm attempting to set the calculation order of a couple fields and I want them to always be last. I know I can set the .calcOrderIndex of a field but that only works if I know what field will be before my "last" field. The way the document is set up is there is a button that adds a sheet from a template, which has N amount of fields on it, I want to always set the calcOrderIndex of "totalAmount" (which is always on the first page) to the last spot.
I thought the best way to do this would be to get the calculation order array, but I can't seem to find out how to access this array.
Any advice will be helpful, maybe I'm looking at this the wrong way, thanks in advance!
You might want to consider using an array of fields by using the hierarchical naming convention i.e field.0, field.1, field.2 etc...
Then you can just get the sum of "field". For a sum, as "totalAmount" implies, the order of execution is irrelevant.
You can loop through the fields and retrieve the calcOrderIndex or each text and combo box field. If it's not a calculated field it will be -1 and can be ignored. You can then reorder as needed.