Suppose that i have two lists
- OFFICES [COLUMNS: OFFICE NAME (Text), OFFICE MANAGER (User), AND OTHER OFFICE DETAILS ETC...]
- EMPLOYEES [COLUMNS: EMPLOYEE NAME(Text), EMPLOYEE OFFICE (Lookup), AND OTHER EMPLOYEE DETAILS ETC...]
Admins of the site are entering offices data and the managers of those offices. I have some event receiver, as they added a new office with manager (which is a User type field), that manager are eligible to enter a new employee for that office (I am achieveing this by custom NewForm. I only display the allowed offices in combobox for Offices lookup)
When that manager enters a employee info (list item), i have another event receiver, which breaks the permission inheritance, and set the Author (manager) contribute permission.
So that, in the Employees List, every manager can display only the list items which are added by themselves.
Everything is OK up to now, my question is: What to do when an Admin changes the manager of an Office in Offices List?
What is in my mind is: Having another event receiver on Offices List on ItemUpdated, and get the New and Previous value for manager. Then go to Employees List and check every List Item that has permission set for the previous manager and remove that manager's permission. Then add new Contribute permission for the new Manager!
Anyone has a better idea? Or what I thought is a good solution?