Button viewed by a specific group of users
I want to make a button which can only be viewed and clicked by a specific group of users. How am I going to do the script.
ok, I suggest that you have to first set up a duplicate layout without the button, and run a script on open to only allow access to a particular layout if a particular user has a name you can test for when they log in - using Get(UserName) or Get ( AccountPrivilegeSetName ) - or just a simple password box that takes them to one layout or the other depending on a code word - that susposedly only you know...
You've actually got two parts to this. Controlling the visibility of the button and controlling it's function when clicked. You don't indicate what your "group of users" have in common. Best guess I can make is that only users with a specific privilege set either have or do not have permission tosee/click this button.
You can "hide" a button in three ways that I know of.
If your button is only layout text or a field that does not have visible borders, you can use a conditional format to make the text or text in the field disappear by setting it's size to 500.
With standard filemaker buttons, you can't use a conditional format to hide the button but you can change the text color to grey to give it a disabled look.
Either way, you have to add an if step to the script that keeps anything from happening if a user that is not part of the approved group clicks the button. (It can still be clicked even though it is not visible or appears disabled.) If [ Get ( accountPrivilegeSetName ) = "supervisors" ] is an example of such a step.
For graphic buttons (either standard fileMaker buttons or graphic objects set up as buttons) you need to use one of two other methods to make them disappear. With either of these two methods, you should not need to add an If step to your script as the button will not be clickable when it is not visible.
You can set up a tab control with two panels and zero width tab labels. If you set transparent borders and a fill color that matches the layout background the tab will be invisible. You can use the name box in the inspector's position tab to give each tab panel an object name. Then a script can use Go to Object ("tab panel Name" ) to select one of these two tab panels. Put your button on one of these tab panel. Go to object in a script can now make the button appear/disappear by selecting the tab panel that does/does not have the button. A script trigger such as OnRecordLoad can then make the button appear/disappear automatically.
You can set up a one row portal to a related table. Since it can be any table that has at least one record, often a self join with the X operator is used. A portal filter on the portal can then control whether any record appears in the portal or not. You can then put the button in the portal row and manipulate the portal filter to make it appear or disappear. (And a FileMaker 10 version of this approach that "filters" at the layout level can also be used.)
Retrieving data ...