I am setting up some layouts, that depending on specific situations, certain buttuns should or not appear. I don't want to create duplicate layouts for each option, if it is possible to show or hide specific objects from a layout.
Unfortunately there is not. Once an object is on a layout, it is viewable. If you dont want the buttons to be viewable for all you would have to create separate layouts.
What i've done is if i have a button that only managers need access to, i'll script an IF statement to check their priviledge set and if they are not supposed to be using the button, show a dialog saying they dont have permits.
In brief, one common method is using a utility relationship and a portal with one related record (and no fields)
which only shows if certain conditions are met; any objects placed on the portal row will appear/disappear along with it.
Remove the line attributes from the portal and uncheck the “change to hand cursor over button” option, and no one will
notice that there is a button.
Another, more recent method uses tab controls, where one tab has buttons and the other doesn't.
I sometimes place a text constant with no fill over the button (with just a single space as the contents), then use conditional formatting to add a fill to the text box that matches the background behind the button when I want the button hidden.
And finally, I add a check to the script that handles the button to do nothing (just exit the script) if the conditions which cause the button to be hidden are true.
Not perfect, as moving the cursor over the hidden button will cause the cursor to change to a hand, but provides an aesthetically-pleasing solution that also ensures the button doesn't do anything when it shouldn't.
You can change the cursor behavior in the Button Setup dialog. The portal solution has a bit overhead, because you need a dedicated TO, but saves you the check in the script, because as far as FM is concerned, there simply is no button to be clicked if the portal record doesn't show.
You can do this with Conditional Formatting. Set the button to have no border lines, and set the fill and text to match the background color of the layout. Apply different conditional formats to it for text and fill based on calculations.
You should also have such buttons set to run scripts, not single-step actions, then you can also test for the correct conditions and have it respond or not when conditions are right.
In FMP v11, I have done this using Filtered Portals.
1. Have a field called "Constant", calculated field equal to "1".
2. In relationships graph duplicate a table (I called mine "Invisibles") and set the relationship to "=" "constant" on both sides & with no boxes checked at the bottom.
3. On the layout create a small portal set to "Invisible", check filter portal records only and set filter calculation to Get ( AccountName ) = "your name or Admin"
4. Place any button in the portal. Set the script to whatever you want and then turn off or uncheck the "change to hand cursor over button".
5. Set the portal background fill to transparent and the line to none and your done.
When signed in to Admin or your name, button will show. When not signed in to "Admin, etc." portal will not show and button will not show. Trick is to not show hand cursor.
Retrieving data ...