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?
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 [ 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” ]
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.
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 ]
The Exit Script [ False ] is the bit you're missing.
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.
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.
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."
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.
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).