8 Replies Latest reply on Oct 25, 2016 10:33 AM by basilisk2

    Button Bar changes script behaviour from Button

    basilisk2

      I replaced FM11 Buttons with the FM14 Button Bar, but using the same script for both.

       

      In the FM11 db, clicking the FM11 style button in Layout A took me to Layout B but maintained the same record. In FM14 clicking the equivalent button in the Button Bar also takes me to Layout B but has forgotten which record I was viewing and goes back to the first record.

       

      The exact same script is used by both buttons. Both layouts are based on the same Table.

       

      Do I need to add something, or does the Button Bar not work that way? If I tried adding "Go to Related Record" I get an error message saying "No related table exists" but it is the same table so surely that shouldn't matter? I am using FMP 14.0.5

       

      TIA

        • 1. Re: Button Bar changes script behaviour from Button
          philmodjunk

          I doubt that it's the change to a button bar that's responsible.

           

          Changing layouts can trip a whole host of script triggers. There may be some script being performed by a script trigger that's changing the current record on you when you change layouts.

           

          The easiest way to find this script if one does not come immediately to mind is to enable the script debugger in FileMaker advanced before clicking this button.

          • 2. Re: Button Bar changes script behaviour from Button
            basilisk2

            Thanks for your help. I shall do what you suggest with the Debugger, but the only change is the button becoming a button bar. The Layouts are the same two layouts as before, the file is the same file as before, the scripts are unchanged, he Table is the same table, the ONLY change was replacing the button with the button bar.

            • 3. Re: Button Bar changes script behaviour from Button
              jormond

              I just tested the button bar with Go to Layout, and it works as expected. In a table with the same context, it remains on the record I was on.

              1 of 1 people found this helpful
              • 4. Re: Button Bar changes script behaviour from Button
                philmodjunk

                The script trigger issue, if it applies here, can be a nasty one to debug sometimes.

                 

                If a script changes layouts, it can trip all of the following triggers:

                 

                OnObjectExit    

                OnObjectEnter

                OnObjectSave

                OnObjectValidate

                OnLayoutEnter
                OnLayoutExit

                OnRecordCommit

                 

                What makes it extra tricky is that it can depend on where the focus is at the moment the script executes as to whether some of these triggers are tripped. If the focus is in FieldA and it has OnObjectExit set up, a click on your button trips that trigger. If the focus is in FieldB and it does not have this trigger set up, then clicking your button does not trip the trigger...

                • 5. Re: Button Bar changes script behaviour from Button
                  Stephen Huston

                  Where on your layout is the button bar located?

                   

                  If it's in a Header part in List View, simply clicking on the button will change focus to the first record in a found set before the script executes. Placing it inside the Body or a Nav part should leave focus on the current record.

                  • 6. Re: Button Bar changes script behaviour from Button
                    basilisk2

                    Thanks for that. I changed one of the buttons from using the script to just changing the Layout Single Step and it worked. I don't know why the script worked when the bar was not there, but stopped working when it was but so long as it works I'm happy.

                     

                    Now I have to change the other six buttons on seven different pages meaning quite a lot of work. I wish there was a way to have a 'global' common menu bar so that it would be possible to change it on every layout it is on, and where it takes the 'Active Segment' as being whichever current layout its instances are placed on.

                    • 7. Re: Button Bar changes script behaviour from Button
                      jormond

                      I will try and play around with this a bit more tonight. We haven't seen anything here that has raised any concern about the script step behaving differently. But I definitely prefer to know for sure. Ending up in the wrong context is typically very bad.

                      1 of 1 people found this helpful
                      • 8. Re: Button Bar changes script behaviour from Button
                        basilisk2

                        Does this only affect List based Layouts? I generally don't use them, preferring Browse mode more often. Perhaps I'm missing out on a good idea?