14 Replies Latest reply on May 12, 2014 7:15 PM by DouglasCourter

    Limiting / Filtering What Records are Visible

    DouglasCourter

      Title

      Limiting / Filtering What Records are Visible

      Post

           I have a database in which only two layouts are visible to users through Custom privileges using the SponsorLogin = Get(AccountName) limitation. This allows a user, in this case a child sponsor, to only view those children that they have sponsored. The problem is, when sponsors log in they have to cycle through all the records that they are not allowed to see (which properly say "No Access")  until they get to the one(s) they are allowed to see. Is there a way to avoid this cycling through the records and only let them see the ones they are allowed to see? I am using FM12. Thanks.

        • 1. Re: Limiting / Filtering What Records are Visible
          philmodjunk

               You can create a script that performs a find and use File Options to set that trigger to be performed OnFirstWindowOpen. Any find performed while is open via one of these limited access passwords will automatically omit all <no access> records from the found set.

               You might just use get ( accountName ) in a script to perform a find for all records for which the current user has access, see: Scripted Find Examples for examples of scripted finds that can do this, or you might just set up a find that specifies the * wild card operator in a field that is never empty in this table.

          • 2. Re: Limiting / Filtering What Records are Visible
            DouglasCourter

                 I'm getting there. I created a script to set a Global value, then do the find as you indicated. I can get it to work on my local machine, but it doesn't work through Web Publishing. It still gives me the "no access" on all the records until I cycle to the records that do fit the criteria. It is if the find is not working. Any suggestions. I have attached a snippet of my script which runs on Layout Open.

            • 3. Re: Limiting / Filtering What Records are Visible
              philmodjunk

                   You don't actually need the global field. The set field can simply use:

                   "==" & Get ( AccountName )

                   as the second parameter of the set field step.

                   When you say "web publishing" what specific form of web publishing? Web Direct? Instant Web Publishing? Custom Web Publishing?

                   I would assume from what you have posted that you mean either the first or second option. How are you running this script? If you put a button on the layout and click it to run this script as a test, what result do you get?

              • 4. Re: Limiting / Filtering What Records are Visible
                DouglasCourter

                     I am using Instant Web Publishing with a test login to test things. I have set the particular layout to display by default when a person logs in. The script is run OnLayoutEnter.

                • 5. Re: Limiting / Filtering What Records are Visible
                  DouglasCourter

                       I also need to make sure the person can not click the "Show All" button to see what they are not supposed to see. Since I can't get this to work on my test login, I don't know if that button is available or not.

                  • 6. Re: Limiting / Filtering What Records are Visible
                    philmodjunk

                         You cannot directly trip script triggers from a web browser when publishing to the web with IWP. Thus, it not only seems like the script is not running, it really isn't running in that context. You'll need to come up with another way to run this script. (You can use FileOptions to run this script when the file opens or a "navigation button" used to go to the layout can perform a script that both changes layouts and performs the find.)

                    • 7. Re: Limiting / Filtering What Records are Visible
                      DouglasCourter

                           I've gotten it really messed up now, but maybe that's progress. I created a layout with just one button on it so far. I set the button to run the script I had been trying to run through the other layout (the one shown in a previous post with the one change you suggested made). Now, when I press the button I get a message which says "Your access privileges do not allow you to perform this action." The Sponsor Privilege set has custom privileges Record Privileges set to limited view. The Custom Layout Privileges are set to allow the Menu, Sponsors Entry & SponsorsView (the one I've been trying to get working) all set to view only in Layout & Records. Does this help any?

                      • 8. Re: Limiting / Filtering What Records are Visible
                        philmodjunk

                             It's hard to say from here as that particular message (like many FileMaker error messages) doesn't provide much info as to what produced the error. First, make sure that this privilege set is allowed to execute scripts (all executable only and not set to "no access").

                        • 9. Re: Limiting / Filtering What Records are Visible
                          DouglasCourter

                               Perfect! That was it. It allows my test login to only see the records I want and disables the View All. Now I"ll set it up for the other form as well. Thanks! I'll eventually get the hang of FM. I'm a long-time Access programmer and FM does things very differently.

                          • 10. Re: Limiting / Filtering What Records are Visible
                            DouglasCourter

                                 Now, it is not working. I have created a layout with two buttons each of which takes the sponsor to a layout. Each layout has an OnLayoutOpen script which I have included in the attached file. When I click either of the buttons I get a permanent hourglass with the word esc near it. On the server on which the database is hosted it does something that requires them to reset it before I can get any access to it. They said that a script is somehow locked in run mode, if that makes sense. Any suggestions?

                            • 11. Re: Limiting / Filtering What Records are Visible
                              philmodjunk

                                   It looks like you have set up a script performed by a script trigger that trips its own script trigger and thus locks into an infinite loop. If I understand what you set up, You have this script set up with the OnLayoutOpen trigger on the "Sponsers Entry" layout. Note that the first line in your script is Go To layout ["sponsors entry" (Sponsors)] and this then trips the very script trigger that performed the script in the first place.

                                   Try removing the first line of your script if you are going to keep the script trigger in place. But there really isn't any need for an OnLayoutOpen script trigger here if you are going to only use navigation buttons to access this layout. Set up the button to perform this script and remove the script trigger.

                                    

                                   So I would test this on a local copy with FileMaker Advanced. You enable the script debugger and then click the layout navigation button. Each trigger performed script will pop up in the script debugger so this is the best way to check for all such trigger controlled scripts that might be involved in this process.

                              • 12. Re: Limiting / Filtering What Records are Visible
                                DouglasCourter

                                     That worked perfectly. I removed the OnLayoutOpen trigger and just called the script from the button. However, I still have one problem. In one table the sponsor is able to see all information about the children s/he sponsors and is not able to change anything. That is the way we want it. In the other table we want the sponsors to be able to update their contact information, but all the sponsor sees is "No Access" in every field. I thought I had enabled record access in the security section, but I must not have done something right. Any ideas. I can give you screen-shots of whatever might help.

                                • 13. Re: Limiting / Filtering What Records are Visible
                                  philmodjunk

                                       You'll need to examine the "lock expression" used to control which records are visible and editable. It would appear that this detail is not correctly set up for your user's privilege set.

                                  • 14. Re: Limiting / Filtering What Records are Visible
                                    DouglasCourter

                                         Thanks. I had opened up the layout, but not the records. Everything is working as needed now. Thank you so much!