3 Replies Latest reply on Jul 15, 2010 1:34 PM by Steve Wright

    How to get a field to be evaluated constantly.

    BERGSTEN

      Title

      How to get a field to be evaluated constantly.

      Post

      I have a discount field where I can imput different percentages for whole invoices. The problem is, however, that I can't get the discount total field to recalculate automatically when I change something on the invoice.

      The calculation reads:

      Subtotal *  Discount

      and the "Do not evaluate if all referenced fields are empty" box is checked

      and the Do Not Replace Existing Value Box is UNchecked.

      I have a tax checkbox that evaluates MA state sales tax and it recalculates every time something on the invoice changes.

      The taxation calculation is the following:

      If ( Taxable = "Yes" and Subtotal ; (Subtotal - Discount_Total) * .0625 ; 0  )

      ^^I did not write this, PhilModJunk did to help me, so I don't understand what exactly it does so that I would be able to use it for the Discount field.

      Thanks!

      FMP11, XP

      totals.jpg

        • 1. Re: How to get a field to be evaluated constantly.
          philmodjunk

          Instead of using a number field with an auto-entered calcualtion, use a calculation field with this expression. This field should update automatically.

          Auto-entered calculations do not update automatically if the value changed comes from a different table.

          • 2. Re: How to get a field to be evaluated constantly.
            BERGSTEN

            I have two questions about this:

            1). If I change this now, will this change everything I've entered in this field thusfar?

            2). Will I be able to enter a number of my own choosing in this field? (For example, if instead of giving someone a discount by percentage, I just wanted to give them a $100 discount).

            • 3. Re: How to get a field to be evaluated constantly.
              Steve Wright

              You could use a script trigger too.
              Set an OnObjectSave trigger on the discount field to run a script which is basically one line..

              Set Field [Discount Total] SubTotal * Discount

              You could also expand on this, such as 

              If [not isempty (Discount Subtotal)

              Show custom dialog [ "do you want to replace the existing discount total with the new figure of " & discount * total ]

                  If [get(LastMessageChoice) = 1]

                      Set Field....

                   [else]

                      Exit Script[]

                   [end if]

              [else]

                   Set Field....

              [end if]