2 Replies Latest reply on Sep 17, 2012 3:29 PM by MorkAfur

    Filtering/Showing Records Based on logged-in User?

    MorkAfur

      Title

      Filtering/Showing Records Based on logged-in User?

      Post


           Hello,

           When I enter a layout, I only want to see (be able to browse at all) those records for which the userName field matches the logged in User (Get(AccountName)).

           However, I don't see anyway to do this. If I try to do a Find[] command, it expects me to enter static text, not a calculation, so no way to enter Get(AccountName) to filter the Find.

           If I try to filter records in Permissions, then all I can do is make them not accessible, but they still are scrollable.

           Say you have 50,000 records and only two of them are for user "Bob". What I'd like to have happen when you go into that layout is only the records for "Bob" appear and are scrollable. So I should only see two records when I click next.

           How to do this kind of auto-filtering?

           Thanks,

           -m

        • 1. Re: Filtering/Showing Records Based on logged-in User?
          philmodjunk

               If I try to do a Find[] command, it expects me to enter static text, not a calculation, so no way to enter Get(AccountName) to filter the Find.

               There are ways to enter search criteria produced by evaluating a calculation.

               Here's one example:

               Enter Find Mode []---> clear the pause check box here
               Set Field [yourTable::username ; Get ( accountname ) ]
               Set error capture [on]
               Perform find []

               But if you use access permissions to limit access to the records, you don't need to do even that. Any find performed will autoamtically omit "no access" records. Here's a "find all records you are permitted to see" script:

               Enter Find Mode []
               Set Field [YourTable::username ; "*"]
               Set error capture [on]
               Perform FInd[]

               You can put that asterisk into any field in YourTable that is never empty and you will get the same results--all records except those to which access permissions prohibit access.

          • 2. Re: Filtering/Showing Records Based on logged-in User?
            MorkAfur

                 Thanks Phil,

                 I had figured out the first method above and was trying to update my posting, but you're too fast!!! :)

                 I'm printing out your answer and adding it to my FMP goodies!

                 Thank you very much.

                 -- Jim