10 Replies Latest reply on Feb 5, 2012 1:14 PM by arronman

    Script to change layout visibility on user login?

    arronman

      Title

      Script to change layout visibility on user login?

      Post

      Hi Guys,

      I have a database used by 4 different people.  I have created scripts to customise reports for each of the users.  Trouble is I now have 4 different copies of some of the reports which are unique for the individual user. I don't want the reports all visible to all users, only those applicable.

       

      Can I create a script which will activate at the time the file is opened so that only the appropriate set of layouts (reports) are displayed, the remainder being invisible? Any suggestions?

       

      Is there a way of doing the same with script visibility?

        • 1. Re: Script to change layout visibility on user login?
          philmodjunk

          In File Options you can select a script to run when the file opens.

          Thus, you can set up a script that uses Get ( AccountName ) to identify the user and then select a starting layout appropriate for that user. If you remove all layouts from the layout drop down when in browse mode. (There's a check box for this in layout setup...), you can then put buttons on the layouts that take the user to different layouts. This gives you a number of ways to control which layouts are accessible to the user. You can even put your own global text field on a layout with a drop down of layouts appropriate for the current user and add a script trigger that uses the value selected in this drop down to select a layout to go to and then go to that layout.

          • 2. Re: Script to change layout visibility on user login?
            arronman

            Too easy!  At first glace it seems quite straightforward.  Thank you.

            • 3. Re: Script to change layout visibility on user login?
              arronman

              Not too easy for me, unfortunately ... I can set up the buttons, etc on starting layouts, no problem, but how to configure the script using Get(AccountName) and going to the appropriate layout?

              Clearly I'm not yet a power user.

              Let's say I have AccountNames "User1" and "User2" with starting layout names "StartU1" and "StartU2".

              Where do I start?

              Go to Layout? If? ????? What?

              • 4. Re: Script to change layout visibility on user login?
                philmodjunk

                If [Get ( AccountName) = "User1" ]
                    Go to layout ["startU1" (    ) ]
                Else If [Get ( AccountName ) = "User2"]
                     Go to Layout ["StartU2" (     )]
                Else
                      Show custom Dialog ["Error: Unknown account name"]
                End If

                That's the simplest, least flexible method. You can also use Get (AccountPrivilegeSetName) to identify groups of users when all users of a given group need to start with a specific layout.

                You can also set up a table of account names or privilege set names where you also store the name or number of the starting layout. Then the script can find the correct record for the current user in this table and go to the layout named in that record.

                • 5. Re: Script to change layout visibility on user login?
                  arronman

                  Thanks a million. Beginning to understand how to construct scripts.  And thanks for flexibility tips.

                  • 6. Re: Script to change layout visibility on user login?
                    arronman

                    Yes! It works as it should.

                    There's just one minor thing: sometimes (FM Go on iPad) a window (from last time file opened?) flashes up then dismisses just before the Start layout loads.

                    Less than a second, but looks messy.

                    Would this be stopped by running a script on close file that shuts all layouts? Is possible?

                    • 7. Re: Script to change layout visibility on user login?
                      philmodjunk

                      It can't shut all layouts, but it can select a blank layout. If this is a file hosted by FileMaker Pro or FileMaker server, you can make sure the desired layout is selected just before you close the file and put it up on the server to be hosted. (Client sessions will then default to that layout each time they access the hosted database.)

                      • 8. Re: Script to change layout visibility on user login?
                        arronman

                        Thanks.

                        Still have a problem, though.

                        Want to be able to have a log in with full admin priveleges. No problem with a work-around opening file with Filemaker Pro, but with Filemaker Go, an admin user can't see the full layout menu (quite a few layouts) and also manage scripts.

                        Can I set a start screen for admin priveleges which enables all the layouts to display, while disabling the Layout selector (ie nav buttons on screen only) for those with restricted priveleges?

                        • 9. Re: Script to change layout visibility on user login?
                          philmodjunk

                          You cannot make changes to your solution with FileMaker Go regardless of the password used. Design changes must be made on a regular computer with FileMaker Pro. THen the udpated file is transferred back to the iOS device via iTunes.

                          In FileMaker Pro, a full admin user can access all the layouts in your database file by first entering layout mode. Then every layout that exists will be listed in the layout drop down.

                          If you need a more precise control of this or you want it in browse mode, you'll need to set up a text field, usually with global storage specified, with a value list of layouts that you create and maintain. You then need to attach a script trigger to this drop down to run a script that uses Go To Layout to go to the layout selected from the value list.

                          • 10. Re: Script to change layout visibility on user login?
                            arronman

                            OK.  That's not a dealbreaker. Admin users have the technology. Probably safer as we don't want the FMGo imput user mucking about.

                            Thanks again for your clear analysis and presentation.