AnsweredAssumed Answered

Sum Function not working on portal data

Question asked by DanielShanahan on May 31, 2015
Latest reply on Jun 1, 2015 by siplus

For some reason, I cannot get the Sum () function to consistently calculate my portal lines.  On the Invoice layout, I update a field in the portal which shows the invoice lines.  A trigger on the field calls a script that should update the totals.  See the screen shots below.


This is in FM13 on a Mac, OS 10.10.3.


eSQL SUM () works fine, so I can change the code to use that instead.  But why doesn't FM's native Sum () function work?


Screeen shots:


01_Sum_Lines shows two lines that are correctly summed.  A script grabbed the Qty from another layout, so these lines went through a slightly different process than getting triggered from manually adding the Qty.  In any case, notice that the Subtotal and the Sum () function in the data viewer are correct.


02_Sum_Lines shows a new line item.  The Qty of 5 was added manually, which triggered an OnObjectSave script.  Notice that the Subtotal and data viewer are not correct.  It should read $574.98.


03_Sum_Lines shows the triggered script as I step through it in the debugger.  Notice that the variable $subTotal does not update correctly, which you can see in the data viewer.  I commit the record prior to setting the variable but that doesn't help.


04_Sum_Lines shows that the field INVOICELINE::lineTotal is a number field.  Originally, I had the index set to None with "Automatically create indexing as needed" checked. Since that wasn't working, I manually set this field to index All.  Still doesn't seem to help.


05_Sum_Lines shows the relationship between INVOICE and INVOICELINE.


According to FileMaker's documentation, this should work.  Anyone have any ideas why it doesn't?