10 Replies Latest reply on Aug 29, 2013 1:45 PM by wsvp

    Script Triggers used on Tabs


      I ask, once again, for help from those smarter than I. Here's what I'd like to accomplish:

      Screen Shot 2013-08-29 at 2.07.46 PM.png

      Here's the script I'm calling:


      [ interface_main::Current_Priv="User" ]

      Perform Script [ “NoAccess” ]
      Else If [ interface_main::Current_Priv="admin" ]

      Exit Script [ ] End If

      Nothing happens when I'm logged in as "User."


      Clearly, I don't know what I'm doing.

      Thank you in advance for any advice


        • 1. Re: Script Triggers used on Tabs

          How does interface_main::Current_Priv get its value? What does the "NoAccess" script do? Is the script actually being called or are you hoping this runs when the default tab pops up?

          • 2. Re: Script Triggers used on Tabs

            interface_main::Current_Priv comes from the privileges set up in accounts.


            The system currently works. This is just a new layout I'm thinking of. Id like to restrict certain parts of the interface based on privileges. "interface_main::Current_Priv" comes from the current interface file.


            "NoAccess" script is this:



            Global Scripts: NoAccess
            [ If ( interface_main::Current_Account = "admin" or "developer" ; 0 ; 1) ]

            Exit Script [ ]
            Else If [ If ( interface_main::Current_Account = "sales" ;0 ; 1 ) ]

            Show Custom Dialog [ Title: "No Access"; Message: "You don't have access to this function"; Default Button: “OK”, Commit: “Yes” ]

            End If
            Exit Script
            [ ]


            Again, nothing changes when I'm logged in as "User." Still have access to the tabs I'm trying to lock down.


            Thanks for responding.


            • 3. Re: Script Triggers used on Tabs

              Well, nothing in your scripts actually prevents the tab switch.


              I think a single script is all you need:


              If [ ( interface_main::Current_Account = "sales" ) and ( interface_main::Current_Priv = "User" ) ]

              Show Custom Dialog [ "Blah, blah, blah" ]

              Exit Script [ False ]

              End If


              The Exit Script [ False ] is the bit you're missing.

              • 4. Re: Script Triggers used on Tabs

                Thanks. Doesn't work. "sales" still has access to the tabs I'm looking to exclude.


                Not sure if it's where I'm placing the script triggers (OnTabSwitch), but it seems that no matter where I place it, there's no way to exclude "user" from the tabs.

                • 5. Re: Script Triggers used on Tabs

                  You need to figure out if you're really testing the right account. Does the dialog show up? How do you know you're actually testing "sales"? How do the Current_Account and Current_Priv fields get their values? You've go to give some more information. Post a demo file.

                  • 6. Re: Script Triggers used on Tabs

                    When logging in under different account, the correct user account shows up on the menu screen (there is a merge field which shows both (just for testing) user account and privileges. So I know I'm testing the right accounts.


                    Demo file not possible, as I'm modifying a commercial solution the code for which I've paid. It's "confidential."


                    Appreciate the shorter script. This is an issue that many FileMaker folks seem baffled by (apparently, judging by the number of links that google brings up about this same question). Every "solution" I've searched brings up the same result: nothing happens.


                    BTW, no dialog shows up. Nothing, literally nothing happens when switching tabs under the current account "sales" with current privileges "User."

                    • 7. Re: Script Triggers used on Tabs

                      Try this, just to see that it should work if you're querying the correct credentials. Log in as "Admin" or as "User", without password.

                      • 8. Re: Script Triggers used on Tabs

                        Did you set up the Get ( TriggerCurrentTabPanel ) and/or the Get ( TriggerTargetTabPanel ) functions in the script.  These will return the Tab number as Value 1 and the Tab (object name) as value 2.  These functions need to be set in the script (not as script parameters)...  this process does work once you understand it... But... FileMaker did an awful job in the documentation related to this, so I would expect to see a lot of users confused by the process.

                        • 9. Re: Script Triggers used on Tabs

                          Your little file works as expected. Thanks.


                          However my big file still doesn't work (I took note of your "flush cache results" step...good idea all around).

                          • 10. Re: Script Triggers used on Tabs

                            No, I didn't, but neither did the gentelman who sent me this, and his works. I'll come back to this another time. I have bigger fish to fry right now. Thanks all.