4 Replies Latest reply on Aug 4, 2014 8:47 AM by philmodjunk

    Summary Field won't Automatically Recalc

    ABuchtel

      Title

      Summary Field won't Automatically Recalc

      Post

           Hello!  I have a portal on a form-view layout, with many other elements. That portal is for the "Events Menus" table which tracks the menu items ordered by a customer (similar to an Invoice). I have a Calculation Field, c_LineTotal, which multiplies the Quantity by the Price. I have a Summary Field, c_MenuTotal, which is the Total of c_LineTotal.

           The c_LineTotal field is within the boundaries of the Portal. The c_MenuTotal field is outside of the portal as a field on the layout.

           On that same form-view layout I also have a "View Menu" button that opens a report showing that specific Menu in a separate list-view layout.

           When I change the Quantity or Price, the c_LineTotal automatically updates, but the c_MenuTotal does not. I have to click the "View Menu" button or close the current layout and reopen it, in order for the  c_MenuTotal field to recalculate.

           Can someone tell me what am I doing incorrectly, or what I might try to get this field to automatically recalculate without those gymnastics? I have attached screenshots of the relevant field information so you can see how they're setup. Thank you! 

      SummaryWontRe-calc.jpg

        • 1. Re: Summary Field won't Automatically Recalc
          symbister

               again, Commit Records is the step to use to 'force' an update - use it in a triggered script in required fields

          • 2. Re: Summary Field won't Automatically Recalc
            philmodjunk

                 Using a calculation field defined in the layout's table which uses the sum function to create this total will update more smoothly than a summary field defined in the portal's table.

            1 of 1 people found this helpful
            • 3. Re: Summary Field won't Automatically Recalc
              ABuchtel

                   Following symbister's advice, I created modified the "Quantity" field to have an "On Object Exit" Trigger. That Trigger performs: "Commit Records/Request [No Dialog]". Upon testing, I see that the Trigger only works about 75% of the time. In other words, about 75% of the time that I change the Quantity, the Sub-Total field updates, and about 25% of the time it does not. Sometimes the field is entirely empty. I need to force a refresh by exiting the layout and returning. I am the only one working on this database which at the moment is located on my laptop. 

                   Following PhilModJunk's advice, I created a c_SubTotal field in the table (Events) on which the layout is based. I defined c_SubTotal to be a Calculation field: Sum ( Event Menus::c_LineTotal )  In testing, this has performed consistently.

                    

                   Thank you both for your help!

              • 4. Re: Summary Field won't Automatically Recalc
                philmodjunk

                     Commit Records
                     Refresh Window

                     Is likely to be 100% consistent

                     and with FileMaker 13, I suspect that

                     Commit Records
                     Refresh Object

                     would also work if you gave the summary field an object name, but I prefer Sum() in these cases as I usually do not need any script at all (unless there is some other factor in play that keeps sum from updating and that can be the case sometimes.)