SHowing List Items based on Level of Users
I have a following requirement.
My SharePoint site has a set of users.
Now some users are employees (level 1), some managers (level2), some Sr.Manager(level3). Like this I have a hierarchy having users up to 5 levels.
Now all of them make leave applications, and their superior approves\rejects them. It gets stored in a list, which stores the rel开发者_运维技巧ative details of the application including the requestor and approver.
Now, when a user logs and browses to a Leave Report page, he should be able to view his/her leave records + leave records of all the users which are below him in the reporting hierarchy.
e.g. If a user of level 1 logs in he should be able to view his own leave records + level2-level5 users leave records.
As of now the users are just stored in one group called Site Owners.
How can I approach this? How should the users be stored and how can I create the Reports.
You can use custom form template. Take a look at http://pioneeringsharepoint.blogspot.com/2009/11/correct-way-to-customize-forms.html.
The key is to override the IsFieldExcluded property to check the user level and exclude the field if needed.
First, I would take all of the users out of Site Owners if that group has Full Control to your site (which it should by default). Then I create five groups: Level 1, Level 2, Level 3, Level 4, and Level 5. Place the appropriate user in the appropriate group.
Next, I would add an Event Receiver to the list. On ItemAdded, call BreakRoleInheritance(false) to set the Item Level permissions. The current user is granted permissions by default, so all you would have to do is grant Read permission the level groups above that user's group.
精彩评论