2 Replies Latest reply on Jan 14, 2013 10:28 AM by philmodjunk

    Script trigger problem



      Script trigger problem


           I have a customer db setup with a tabbed screen section for "purchase history"  I have written a script that takes all the info on that tab (date, item, sale amount) and copies and pastes to a field titled "purchase history archive"  Once archived then I can add new purchase information. 

           I have put a script trigger in the date field so that when an existing customer comes back and makes a purchase I can enter the date field to post a new date but it will archive information before i do that.

           Here is the problem...

           I have set the trigger in the date field  onobjectenter.  When I enter the field the info is copied properly but then the curser stays in the archive field.  If I then go to the date field again of course the script triggers again and i have duplicate information in the archive field.  If I add a gotofield command to the script then I get a loop copying and pasting repeatedly until I stop the script.

           I know I am missing something simple but cannot seem to figure it out. 


           I am using filemaker 11 advanced pro - Mac

           A copy of my script is attached in a jpeg file

           Thanks for any help you can give.



        • 1. Re: Script trigger problem

               Use 'Set Field' instead of 'Copy/Paste'.

               Also deselect 'Run script with full access privileges'. Use that with caution.

          • 2. Re: Script trigger problem

                 I think that you have a lot more than just a script trigger problem here.

                 There are ways to get a script trigger controlled script to check a value in a variable or a field to keep from being tripped when it should not be, but your script and database design have a lot of other issues.

                 Copy/Paste script steps are not the best way to move data from field to field and record to record. They will silently fail to copy or paste if the specified field is not physically present on the layout and with behavior settings that permit browse mode access. The script steps that start with "Insert" also have this limitation. Copy will destroy any data that a user has copied to the clipboard prior to performing a script with the copy step in it. Most users find this confusing and annoying and there are ways to use set variable and set field that do not affect the contents of the clipboard.

                 Your script pastes more and more data into a single text field. The resulting mass of text will be very difficult to work with--becoming more unwieldy with each new order by the same customer. Among other things, this makes it difficult for a script to check to see if the data it is about to paste is already present in the field.

                 I recomend that you use more than one table and not copy any data to a history field. One table can have one record for each customer. A second table can have one record for each customer purchase. A third table, if needed can list the individual items that make up a given purchase. And yet another table can function as your "catalog" of items available for purchase.

                 With this set up, starting a new order is simply a matter of creating a new record for that new order--with no need to copy any data.