11 Replies Latest reply on Dec 17, 2013 11:19 AM by philmodjunk

    script trigger

    PeterMontague

      Title

      script trigger

      Post

           I want to set a number field every time a calculation field changes. I have a script trigger that runs every time the field is modified. But When I use the replace field contents step the set field step does't work.

           Which script trigger should I use?

        • 1. Re: script trigger
          philmodjunk
               

                    But When I use the replace field contents step the set field step does't work.

               Huh?

               Do you mean that you can use Replace Field Contents to modify the data in the field without tripping the script trigger?

               Don't know of any script trigger that can be tripped by this action. You'll need to figure out a different approach to get the results that you want.

          • 2. Re: script trigger
            IT_User

                 Replace Field Contents will not activate a script trigger. http://www.filemaker.com/12help/html/create_layout.9.57.html#1053469

                 I'm sure there is a different way to do this, like using an auto-enter calc on a field with the "Do no replace existing value" unchecked.

                 If you explain what you are trying to do, it may be helpful to know.

            • 3. Re: script trigger
              SteveMartino

                   By what process is the calculation changed?  If done by entering information in another field, could that field then be used with any of the OnObject(Modify, Validate, Save or Exit) script Triggers?

              • 4. Re: script trigger
                PeterMontague

                     I have a quantity calculation in my inventory that is Sum(transactions::In) - Sum(transactions::Out). When I perform a find in this field it takes a long time. To try and save time I decided to make a new quantity field called quantity alternative. This number field is supposed to update every time the quantity field changes. I wanted to use the set field script step for this purpose. I thought a script trigger would work for this. 

                     It appears I was wrong. 

                • 5. Re: script trigger
                  philmodjunk

                       What you can do is set up buttons and script triggers that update the number field if: a) a value in transactions::In is modified, b) transactions::Out is modified, or c) if a Transactions record is deleted.

                       You would update the total for this one inventory item each time one of those three events take place.

                  • 6. Re: script trigger
                    PeterMontague
                         Thanks for your advice everybody. 
                         
                              What you can do is set up buttons and script triggers that update the number field if: a) a value in transactions::In is modified, b) transactions::Out is modified, or c) if a Transactions record is deleted.
                         
                              You would update the total for this one inventory item each time one of those three events take place.
                         A script trigger won't work if I change several records by using replace field contents. 
                         I could insert a looping set field script that searches for modified records and updates their quantity. 
                    • 7. Re: script trigger
                      philmodjunk

                           That is correct, but what is not clear from your posts is why you need to do such a batch update in the first place.

                      • 8. Re: script trigger
                        PeterMontague

                             The reason why I want to set up this script is because we have missing boxes of items from our inventory. Boxes contain various items with different skus. When a box is missing I want to change the quantity available field in the transaction table to 0. I want the quantity in the inventory table to be Sum (Transactions::Quantity available) - Sum (Transactions::Out). When a box goes missing I would like to use replace field contents to change the quantity in Transactions::quantity available to 0 in all records with the same box number. When the box is found again I'd like to use a looping set field script to change the quantity available to the default figure that is in Transactions::quantity. 

                        • 9. Re: script trigger
                          philmodjunk

                               Does your box contain all the same product or might it hold an assortment of products?

                               I still don't see much need for a batch update. Inventory updates should also be logged as new transactions so this should be a case of adding one or a group of transactions records that remove the items from inventory. Then, if found, you do this again to put them back into inventory.

                          • 10. Re: script trigger
                            PeterMontague

                                 Yes it comtains an assortment of items. I guess I should have a looping script make new transactions that set the transactions::out field to the quantity in the transactions::in field. Will that allow the script triggers work?

                            • 11. Re: script trigger
                              philmodjunk

                                   If you use an insert step instead of Replace Field Contents or Set Field, you'd trip the triggers.

                                   But I wouldn't bother. Since I'm using either Replace Field Contents or a Loop with Set field, I'd just include additional code to do the update that would take place if the trigger were tripped. That might not need anything more than a Perform Script step inside the loop to call the trigger's script.