Unstored calculation not updating sometimes
Operating system version
Windows Server 2008 R2 as terminal server, hosted on a different server
Description of the issue
Several users enter a purchase order with several line items, and on rare occassions the total cost prints incorrectly. The formula for TotalCost, an unstored calculation, is If(IsEmpty(purchases::POKeyField); 0; Sum(purchases::ItemAmount) + FreightChg + Tax + FuelChg). purchases::ItemAmount, an auto-enter replaces existing, is OrderQuantity * UnitPrice.
On two examples I was sent, the total cost did not include the last item. The item amounts for the two items printed correctly however.
Even stranger is one where there was only one item, and the total cost was equal to the inventory's unit price of $1.78. The purchase unit price does a lookup to the inventory, but that had been overwritten to $2.30 and a quantity of 1500.
I'm not sure when the calculation becomes correct, but when I look at it, it is correct. I believe somebody said they printed it more than once and it was wrong, then they asked somebody else to look at it and it was correct.
I tried adding Set Variable [$TotalCost; purchaseorders::TotalCost] to try to make it recalculate but it didn't work.
Steps to reproduce the problem
I haven't been able to reproduce it, but the print button commits records and goes to the related records and updates some fields (this shouldn't be necessary, but it's a migrated system and I haven't gotten around to modifying the reports, etc. based on this). It goes to a print layout (based on purchaseorders) and prints with dialog.
Total cost prints correctly.
Total cost doesn't account for all line items or uses old data I guess.
I guess making TotalCost a number field and updating it with script triggers.