0

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?

0

1 Answer 1

1

Why don't you create a SharePoint Permission Group programmatically each time a new Office is created and save the Group name with Office list...

And when employees are added instead of giving permissions to manager on the list item, give permissions to the group... So when the Office is updated and manager is changed, you just need to replace the new manager in the Group!

This way you don't need to touch the Employee list/list items at all, you just play with Groups associated with each Office List Item!

6
  • Actually, this also came to my mind, but there are two things now. Doing what you've suggested will cost me some work as i did everything based on my post. The second is, what about if an admin changes the Office name? I guess I will also go and change the name of the SharePoint group. Then i will again go and check every list item and replace the permission group? So again same thing i guess. Or am i missing something?
    – ozdogan
    Jan 27, 2013 at 22:11
  • 1
    Why do you need to change the Group Name for changing the Office name? Its just a back-end process, end users don't know how you are playing with groups.. You can keep the name of group as "Group-[ID of Office List Item]"... Problem solved... I guess ID will never change :P Jan 27, 2013 at 22:15
  • wow! that means something! :) well done and thank you!
    – ozdogan
    Jan 27, 2013 at 22:17
  • No problem at all, here to help! :) Jan 27, 2013 at 22:17
  • 1
    Well don't know about BEST PRACTICES... but when it comes to such custom business requirements, I think you need to go off the shelf.. At least if I had that requirement, I had gone the same way, or more over you are using OOB List Forms, I might have replaced them with Visual Web Parts hehe Jan 27, 2013 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.