1 2 Previous Next 16 Replies Latest reply on Nov 30, 2011 2:04 PM by hobbiesdeveloper

    Filemaker scripting problem , please help!

    hobbiesdeveloper

      Title

      Filemaker scripting problem , please help!

      Post

      Hello,

      I'm having a few problems with a couple buttons running scripts, one is getting my next button to toggle to the next record, for some reason whenever I click on the next button which triggers the Go to Record/Request/Page [Next] it just goes to the last record, it looks like it automatically is looping through the next Button trigger even if I don't have anything in the script saying it to loop, could someone please help me figure out what the problem is?

       

      Also, i'm having problesm with the script in adding the record. Everytime I click on the new record scripted button it creates a new record but also goes to the main layout page for some reason? I'm just asking it to create a record on the page I'm on with no other commands but for some reason it goes to my first layout, please help?

       

      Thanks.

        • 1. Re: Filemaker scripting problem , please help!
          DavidJondreau

          1) Check the script step and make sure it's not set to Go to Record [LAST]

           

          2) What is the script that is called with the New button? It's probably part of the script to go to the other layout. Or it's possible you have a script trigger on the layout that's being called.

          • 2. Re: Filemaker scripting problem , please help!
            hobbiesdeveloper

            I will check on that.

             

            Thanks.

            • 3. Re: Filemaker scripting problem , please help!
              philmodjunk

              If you have FileMaker Advanced, you can enable the script debugger, then click your buttons to see what script is performed and you can click a button in the script debugger to advance through the script one step at a time. This can often make the problems with your script easy to find and fix. If you have layout based script triggers involved, this can often be a major "aha" moment when you see script triggers being tripped in unexpected ways by your original script.

              If you do not have advanced, you can insert Show Custom Dialog steps in strategic points in your script to get a better idea as to what is happening in your scripts when they are performed.

              If all else fails, you can post the scripts in question here for others to see:

              To post a script to the forum:

              1. You can upload a screen shot of your script
              2. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF.
              3. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
              4. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional look to your script. (Use the HTML option and paste the text into the HTML editor.)
              • 4. Re: Filemaker scripting problem , please help!
                hobbiesdeveloper

                Excellent. I will go ahead and give it a try.

                 

                Thanks for all your help.Smile

                • 5. Re: Filemaker scripting problem , please help!
                  hobbiesdeveloper

                  I tried everything and the script trigger still loops infinity. I have a container field with a set script trigger option selected and have the OnObjectEnter Event selected and with a script attached to create a new record "New Record/Request". Whenever I click on the container field it creates a never ending amounts of blank records due to the trigger still being active for some reason. It looks like whenever I click on the container field the trigger is activated and it just loops non stop, the only option I can do is by clicing ESC to exit out of the loop. Could some one please help, this is very frustrating. Just trying to create a script trigger on a container field to act like a button but without the wierd background onclick color.

                  Any help is very much appreciated.

                  Thanks :)

                  • 6. Re: Filemaker scripting problem , please help!
                    philmodjunk

                    Until now I haven't had a sufficiently clear picture of what your script is set up to do.

                    New record/Request creates a new record. Your cursor then enters the field in the new record and this triggers yet another OnObjectEnter event on that field which then creates another new record and the cycle repeats.

                    Why are you using the OnObjectEnter trigger on a field to create new records? Setting it up as a button would be much simpler.

                    There are two possible solutions to the basic problem:

                    Use Go to Field, go to object or possibly commit record to get the cursor out of this field. (make sure that it is not the first item in the layout's tab order.) Then create your new record.

                    Use a global field to keep the trigger from repeating after the first call:

                    IF [not $$TriggersOff]
                       Set Variable [$$TriggersOff ; value: True]
                       New Record/Request
                       Set Variable [$$TriggersOff ; value: false]
                    End If

                    • 7. Re: Filemaker scripting problem , please help!
                      hobbiesdeveloper

                      Here is a screenshot of the trigger than I'm running. You are correct, it does trigger another event. I don't want to use a button setup which is the simplest way but leaves a colored background when you click on the button, there is no way to change the color background to invisible for onclick button background which is why I'm using triggers on containers instead.

                       

                      Here is the screenshot of what I have, the plus sign is the add record feature. The "plus sign" picture has no featur but the container on top of it is what I'm trying to make work properly.

                      I will go ahead and try trigger function that you provided and hopefully that will fix the looping problem and end the trigger after the first call of each click.

                       

                      Thanks.

                      • 8. Re: Filemaker scripting problem , please help!
                        philmodjunk

                        The brief color flash you get from clicking a button is a standard inteface design found in numerous applications. I personally don't think the extra effort to eliminate it is worth the result.

                        My last post shared two methods to keep the trigger from triggering itself. Have you tried either of them? I know the second method works as I use it frequently with layout based triggers such as OnLayoutEnter or OnRecordLoad. The first method should work but you may have to experiment with different options a bit before you can get it to work correctly with your layout.

                        Make sure that this field is not part of the layout's tab order. You can check and change this by selecting Set Tab Order... from the Layouts menu while in Layout Mode. If you do not, it is possible to trigger your script by pressing tab, enter or Return while editing the field that precedes it in the tab order (this includes the last field in the tab order if this field is the first in the tab order). (The behavior settings in the inspector control whether tab, enter or return move the cursor to the next layout object in the layout's tab order.)

                        • 9. Re: Filemaker scripting problem , please help!
                          hobbiesdeveloper

                          The formula that you gave me works like a charm.

                          "Use a global field to keep the trigger from repeating after the first call:

                          IF [not $$TriggersOff]
                             Set Variable [$$TriggersOff ; value: True]
                             New Record/Request
                             Set Variable [$$TriggersOff ; value: false]
                          End If"

                          I currently have the Filemaker Training Series book that I purchase directly from Filemaker which doesn't really cover the not function very well. Could you please let me know how the variable $$TriggersOff gets attached to the actual field that the script is running for?

                          It's kind of puzzling in trying to understand that the variable that you created which is the global TriggersOff have a way to control the fields on and off or true/false.

                          Thanks for all your help, I greatly appreciate all your support!

                          • 10. Re: Filemaker scripting problem , please help!
                            hobbiesdeveloper

                            Hello,

                             

                            Just noticed that when clicking the container add record button that I'm using the Trigger formula on it works great, adds 1 record, but when you actually click on the New Record button on the filemaker menu it actually creates 2 new records, it looks like when you click on the New Record button on the filemaker navigation menu it activates my add record field button as well. Would you happen to have a fix for that?

                            • 11. Re: Filemaker scripting problem , please help!
                              philmodjunk

                              First a minor correction of my error. $$TriggersOff is a global variable not a field.

                              It is not attached to any field but is it's own separate variable that will retain any value you put in it until you change it or close the database file. It is global so it can be accessed from any layout and any script in your database.

                              What you were originally getting is a chain of calls to the script trigger's script.

                              The first time it's tripped, the new record/request step calls up a new instance of the same script, which in turn calls another instance and so forth... Should the current instance of such a script terminate, control returns to the next line of the previous instance. In your case, this never happened and you get an endless series of calls to the same script.

                              The change I recommended short circuits the endless chain of calls to the same script by setting a global variable to True. As long as that variable is True, the first line of the script detects that fact and exits the script, returning control to the previous instance of the script. The first script then sets the variable back to False so that it can be triggered the next time the user enters the field.

                              If you haven't already, try running this new script with the debugger and data viewer enabled and watch what shows up in the "call stack" at the bottom of the debugger. You might even run the original set up and watch that section of the debugger to compare the difference.

                              • 12. Re: Filemaker scripting problem , please help!
                                hobbiesdeveloper

                                That definitely makes since.

                                Just noticed that when clicking the container add record button that I'm using the Trigger formula on it works great, adds 1 record, but when you actually click on the New Record button on the filemaker menu it actually creates 2 new records, it looks like when you click on the New Record button on the filemaker navigation menu it activates my add record field button as well. Would you happen to have a fix for that?

                                • 13. Re: Filemaker scripting problem , please help!
                                  philmodjunk

                                  Still have to remind you that you can just use a button and live with the highlight flash. I did say that option was simplest. Wink

                                  Did you try removing the field from the layout's tab order?

                                  Do you have FileMaker Advanced? With advanced, you can set up a custom menu set where the new record option in the records menu performs the same script as your script trigger.

                                  • 14. Re: Filemaker scripting problem , please help!
                                    hobbiesdeveloper

                                    Yes, I do have the FileMaker Advanced version, would you be able to guide me in the right direction in getting the new record option in the records menu perform the same script as the new record script trigger?

                                     

                                    Thanks.

                                    1 2 Previous Next