1 2 Previous Next 24 Replies Latest reply on Nov 14, 2012 9:24 AM by Varndawl

    Account access based on specific field entry

    Varndawl

      Title

      Account access based on specific field entry

      Post

           I want to assign records to specific representatives so that when they log into their account (via web browser) they see a list of ONLY their assigned records. They will then have full access to those records and NO access to any others.

           So where do I start with that? I currently have it set up as a drop-down box with the 10 representatives' names to choose from as I create the records. Could I write a script that would only show records where their name was chosen as the representative? And would that require a different privilege set for every user?

           I think it goes without saying that I'm a complete newbie here :(

        • 1. Re: Account access based on specific field entry
          philmodjunk

               You can use Manage | security to limit access to a specific Account or a specific Privilege Set by setting up a "lock expression" that is true only for records where a value in a field indicates that the current user has access.

               This might be:

               Get ( accountName ) = AccessField

               or it might be:

               Not IsEmpty ( FilterValues ( AccessField ) ; Get ( AccountName ) ) //for cases when there is a return separated list of names in the access field.

               See "Editing record access privileges" in FileMaker Help and check out this particular sub section: "Entering a formula for limiting access on a record-by-record basis" for a detailed description of how to set this up.

               When you have such controls in place, any find performed by a script or by the user automatically omits records for which they do not have access.

               Here's a script that find's all records for which the current user can access:

               Enter Find Mode []
               Set Field [ YourTable::Field ; "*"] ---> find all records where there is data in YourTable::Field
          New Record/Request
               Set Field [YourTable::field ; "="] ----> find all records where YourTable::field is empty

               Set Error Capture [on]
               Perform Find[]

               Note: if there is a field that is never empty, such as an auto-entered serial number field, you can omit the script steps in blue if you enter the asterisk criteria into that never empty field.

          • 2. Re: Account access based on specific field entry
            Varndawl

                 Perfect! Thank you!

            • 3. Re: Account access based on specific field entry
              Varndawl

                   Just getting back to this project and I realized I still have a problem.

                   Here's how I have it set up so far:

                   I have my Field (let's call it Representative) set up to Auto Enter the Account Name that created the record. As an Admin, I have the ability to change that RepresentativeField though by choosing from a drop down list, which contains the Account Names. The other accounts I've set up in a Privilege Set with limited Field Access so they can only view the RepresentativeField. Also, I've limited the view to Get ( AccountName) = RepresentativeField. That's working great, except all the records they aren't allowed to see are showing up with <no access>.

                   I came across this article, but with my limited FM experience, I need more of a step-by-step guide. I don't want to just make those records white or something lame like that. I want to do the scripted Find like "Fenton" suggested. The script you suggested works, as far as finding the records an acct can access, but how do I make it show only those records when they log on?

              • 4. Re: Account access based on specific field entry
                philmodjunk

                     That's the purpose of this script that I have already posted:

                     Here's a script that find's all records for which the current user can access:

                     Enter Find Mode []
                     Set Field [ YourTable::Field ; "*"] ---> find all records where there is data in YourTable::Field
                New Record/Request
                     Set Field [YourTable::field ; "="] ----> find all records where YourTable::field is empty

                     Set Error Capture [on]
                     Perform Find[]

                     This script will hide all "no access" records from the user.

                     You can set this script to be run with the OnFirstWIndowOpen Trigger if you include a go to layout step that specifies the correct layout.

                     You can also include this script in any script that takes the user to this layout. You can use this method instead of the OnFirstWindowOpen trigger if the file always opens some kind of "dashboard" or "Main Menu" layout and they click a button that takes them to this layout.

                     You could also perform this script from an OnLayoutEnter trigger so that if the user selects the layout from the layout drop down in the toolbar, it automatically hides records from the user.

                     If you have FileMaker Advanced, you can install a custom menu set on this layout that uses the above script instead of Show All Records.

                • 5. Re: Account access based on specific field entry
                  Varndawl

                       This doesn't work. What am I doing wrong?

                  • 6. Re: Account access based on specific field entry
                    philmodjunk

                         "Doesn't work" doesn't tell me what results you are getting.

                         Is the current layout a layout based on "newcomer info" when this script is performed?

                         I think I see spaces before and after the asterisk and = operators inside the quotes. I suggest removing them so that you have "*" and "=" respectively.

                    • 7. Re: Account access based on specific field entry
                      Varndawl

                           You're right. There were spaces. Not sure why. Fixed that. Still no luck.

                           This is a screenshot from when I logged on from an account with restricted access - so that only that user's records should be available. All of this happens b/c of the way I've limited viewing in the Privilege Set. I noticed no difference what so ever after running the script. I still get the <no access> records. I have it set for this script to run when a particular layout loads. Maybe I'm missing a step and it's not actually running the script.

                           This is how I currently have it set up: I have my Field (Greeter) set up to Auto Enter the Account Name that created the record. As an Admin, I have the ability to change that GreeterField though by choosing from a drop down list, which contains the Account Names. The other accounts I've set up in a Privilege Set with limited Field Access so they can only view the GreeterField. Also, I've limited the view to Get ( AccountName) = GreeterField. That's working great, except all the records they aren't allowed to see are showing up with <no access>.

                      • 8. Re: Account access based on specific field entry
                        philmodjunk

                             And how did you perform the script? Did you perform it? A simple test is to select this script from the scripts menu and see what happens.

                             And to repeat a question: Is this layout based on the Newcomer Info table occurrence you refer to in the script?

                             If you don't know, enter layout mode and see if "Newcomeer Info" appears next to "Table:" in the tool bar next to the layouts drop down.

                        • 9. Re: Account access based on specific field entry
                          Varndawl

                               Yes, sorry. It is based on the Newcomer Info table. It is the only table I have.

                               I performed the script from the script menu just to make sure, but there was still no change. I was just going to that particular layout before, which is set up to run the script on layout enter.

                          • 10. Re: Account access based on specific field entry
                            philmodjunk

                                 That makes no sense. Numerous developers have used this method with no trouble, but I'm not spotting the difference here that is keeping it from working for you.

                                 Do you have FileMaker Advanced? If so, run this script with the debugger enabled and step through it to see what you see.

                                 If not, are there any script triggers enabled for this layout? (This requires that you specifically set up a script trigger in Layout Setup... or on an object on your layout, so I would guess not, but am checking to be sure.)

                                 Can you post a screen shot of the same layout, but in layout mode and with the tool bar still showing like it is in the last screen shot?

                            • 11. Re: Account access based on specific field entry
                              Varndawl

                                   Sorry to be this difficult. I know it shouldn't be.

                                   I do not have FileMaker Advanced.

                                   There is a script trigger. Attaching a pic of that too.

                                   I can't post a screen shot in layout mode with the same tool bar b/c the previous screen shot was from my browser (using IWP) and I can't go to layout mode from there. So I'm attaching a screen shot of that layout in Layout Mode from FileMaker itself. (I suppose I should have mentioned that this has to work with IWP - don't know if that makes a difference?)

                              • 12. Re: Account access based on specific field entry
                                philmodjunk

                                     An OnLayoutEnter trigger shouldn't interfere with manually running the script from the scripts menu.

                                     From the screen shot, I can confirm that not only is your layout based on Newcomer Info, but that the fields are also from that field and not a related table--which might also result in some no access screens.

                                     Let's try a very basic level test here:

                                     Do this manually:

                                     Enter Find Mode while on this layout.
                                     Specify an asterisk in the notes field or some other data that you know will match to multiple records.
                                     Perform the find.

                                     What results do you get?

                                • 13. Re: Account access based on specific field entry
                                  Varndawl

                                       Hey! That worked! I got only the results that I should have. Now I see what the script is supposed to do. Just not sure why it's not doing the find automatically.

                                  • 14. Re: Account access based on specific field entry
                                    philmodjunk

                                         Do you have a field that always contains data such as a field that auto-enters data?

                                         If so use it and leave out the steps shown in blue. Run that script and see what happens.

                                    1 2 Previous Next