4 Replies Latest reply on Mar 13, 2017 6:01 PM by ch0c0halic

    Script Trigger Execution


      I have a calculation that is repeated each time the value in my Layers field changes. I've assigned the Script Trigger  OnObjectExit:BdFt_Calclation, so that each time the value in Layers is changed, the Board foot (BdFt) value is re-calculated and inserted into the BdFt (field).


      My problem is the value for BdFt doesn't always show in my Reports or Layout. For those records that are missing BdFt, I can got to the Layers field, TAB and the Script Trigger will update BdFt.


      I have a set process for the users that input changes to the database and when I check the table, all of the required values are there but when I look at the BdFt field it's empty. I've also tried changing the Script Trigger from OnObjectExit to OnObjectModify and still have the same problem.


      BdFt is the target field that's set as a result of the BdFt_Calculation script and Commit Records is the last script step.

        • 1. Re: Script Trigger Execution

          Suggestion, make the field an auto-enter-calculation (AEC). If you don't have an auto enter modification timestamp field then add it to the schema.


          Add to the AEC:             Case ( mod_ts = mod_ts ; "your calculation" ; "" )


          Both good and bad is any change to the record will cause it to update.




          Or for finer control of when it updates you could use:


          Evaluate ( expression {; } )


          The fields are triggers to cause the evaluation. There are drawbacks to this as Evaluate ( Expression ) may result in a different answer than the expression alone. For example (used in a script) Evaluate ( Get (ActiveFieldTableName) ) is meaningless inside the Evaluate() but works fine outside of it.

          • 2. Re: Script Trigger Execution

            I am using an auto enter modification timestamp field and I'm not sure where to put the Evaluate ( ) function.


            The board foot calculation script uses the script step; "Insert calculated Result [ ]" this script step does the board foot calculation and places the value into the "BdFt" field.


            So as I said my question is how or where do I use the Evaluate ( ) function?

            • 3. Re: Script Trigger Execution

              Why not just make the BdFt field a calculation field?

              • 4. Re: Script Trigger Execution

                First I suggested NOT using a script. BTW, you are most likely not using an Auto-Enter Calculation if you are using a script. From your description I think you would use one or the other, not both.


                Definition:  AEC is an option in the Field Definitions.


                I would re-define the "BdFt" Field using the AEC option. In its calculation is where you would use the Modification timestamp field and the Evaluate() function, if desired. It is by no means required and depending on your calculation may be undesirable.




                If you must use a script then you probably wouldn't use the AEC option.

                Please use the Set Field script step, not the Insert Calculation Result.

                The Insert script steps require the field be present on the layout. The Set Field step does not.

                In either case follow it with a Commit step so the data is stored immediately.