Unstored calculation not updating

I am having trouble getting an unstored calculation to update on tableview forms correctly and consistently.

I load a global array with values, then my calculated field simply reads a corresponding value from the array to get a quantity.

If I change a value in the array, some of the records in the tableview update correctly and some don’t. If I stop the application and restart, all are updated correctly.

I have a master form, with a tableview form for orders in a tabpanel at the top, and a related tableview form for order items on another tabpanel below. When a record is highlighted above (an order), the items show in the lower table. The calculated field is in the lower items table. If I change the qty field on an item, I update the global array value for that item to keep a running total qty for that item_id for all orders.

After I change a qty, the record I’m sitting on changes correctly. If I select a different record in the above orders table, the calculated field may or may not update. If 10 orders should be showing the same value in the calculated field, 6-8 will be correct, and the others will not be updated.

My calculation in the calculated field is a simple associative array lookup. Nothing else.

FYI: I was using a dataset query to perform this calculation previously, but it too had the same problem updating consistently. I read other posts that said putting queries in calculated fields is not supported, so I rewrote the whole module to use a global array. Now I’m getting the same behaviour. Seems much more like a tableview bug now. Hopefully there’s a simple solution I’m missing though.

Any thoughts? Thanks.

Hi,

I had a simular problem, maybe it helps.
See last reply in this thread :

http://www.servoy.com/forum/viewtopic.php?f=2&t=11535&st=0&sk=t&sd=a&start=15

Regards,

This was helpful, but it still didn’t solve my issue.

I put application.output() inside my calculated field to see when it fires and it’s not firing when I change records in the order grid above, to change the order items in the lower, related grid.

Until this gets resolved, I had to add real fields to my table and update them through a method that fires whenever onRecordSelection fires in the order grid. So I have a workaround in place, but would still like to see calc fields work correctly in table view.

I suspect that changing a value in a global array doesn’t fire the right things to make Servoy know to update calc fields. I could also create an aggregate field that does a sum on QTY and see if that works better. That may be a solution too.

Thanks.

first let me understand this correctly

the calculation depends on a qty field of the record. But if 1 record does change that then also other records in the foundset are related?
Because the are also depending on that change?

That doesnt work yes, because the calculation doesnt know that that it is depending on other rows values.
You could maybe fake this with a self join to the same foundset.

Or else you have to do that yourself with the recalculate function on the database manager (that you call from the onchange of the qty field)