I'm fairly new to Apex and I'm trying to wrap my head around the myriad ways to works with users. At a high level, I have the following scenario:
I am writing a multi-user app which will manage inventory at multiple sites. There are 5 sites: Site1, Site2, Site3, etc...
There are also 3 types of users: admin (can see all data for all sites), pricing-admin (can see certain data for all sites), and site_employeeX (can see all data but only for his particular site X).
So the question is, how can I "assign" a user to a site?
eg: If user site_employee4 is logged in, I want him to be able to only change/see data for site4.
It can't be this difficult -- I must be missing something.
That is not so much an APEX question as a data modeling question. There needs to be a site_employees table with a foreign key to sites which holds one row per employee that has access to the site. Then in the queries you'd join the sites table to the sites_employees table and have a where condition or a join condition employee_name := :APP_USER
.
To assign employees you'd need a form where a user can select a site and add one or more (depending on your requirement) employees.