From SeedCode Documentation

DayBackOnline: OnlySeeMyEvents

How Do I Let a User See Only Their Own Records?

You can easily restrict the events a user is able to see using FileMaker's build in Access Privileges to create rules as to which records a logged in user can see.

If you have't worked with FileMaker's Access Privileges before, take a moment and read the overview in FileMaker's built in help, check out Contents > Protecting databases with accounts and privilege sets > Creating and managing privilege sets > Editing record access privileges.

For more information about limiting which records a user can see, continue to the "Editing record access privileges" page: you're interested in the "Limited" option under number 4.

Tips & Tricks.

The only tricky part here is finding some attribute of the user�s login to tie that login to a record in the calenda's events table. The items you have at your disposal are Get ( AccountName ) and Get ( AccountPrivilegeSetName ). The privilege set name is probably going to be used for general things like "administrator" or "sales rep" so you'll probably be using Get ( AccountName ) in your access privilege calculations to compare a logged in user with the user linked to an appointment. There are two basic approaches here:

1. You can make the user's Account Name match a field already in the database. So you could make sure all your accounts are created with the Account Names being real first and last names of your users. Account names would be things like "Bill Smith". If you did that, an access privilege calc that would let the logged in user only see their appointments would look like this:
Not isempty ( FilterValues ( List ( SampleEvents::UserNameFirstLastCalc ) ; Get ( AccountName ) ) )
Make sure this calc is set to evaluate from the context of the same table occurrence used for your Source No 1 layout. So there are a couple things to note about this calc. The first is that it just returns a 1 or 0; a 1 if the Account Name is one of the names of the users linked to the appointment, a 0 if it is not. That is how all your access privileges calcs should be written: to return a 1 (ie. be true) if the user can see, edit, etc. the record. The second thing to note is that we don�t use the = sign. This is because an appointment can have more than one user, so its user will never be equal to any one user. Instead we use FilterValues to see if the Account Name "is a member" of the users on the appointment.
2. The second approach is to create your own field in a users table to match the account name; you'd essentially be recording the account name in FileMaker. Do not, of course, record the user's password in FileMaker as that would not be very secure.
Note that if your user name is not indexed in the events table this calc can really slow the solution down as FileMaker looks at some related information for each event it is trying to display.
Now of course you may want to have some users that can see everyone's appointments: you don't have to mess with the calc above to do this, simply assign these power users to a different privilege set that doesn't limit the appointments they can view at all.
Note that we're still talking about the user's FileMaker account name, not their DayBack user name which is often their email address. You can map DayBack user names to real FileMaker accounts in the PHPrelay file on your FileMaker Server.
Retrieved from http://www.seedcode.com/pmwiki/index.php?n=DayBackOnline.OnlySeeMyEvents
Page last modified on January 19, 2018, at 10:47 PM