Question

I have list in which a column is of type Person or Group. My requirement is the item permission of another list item need to be changed to the selected value from the above mentioned column.

For eg I have two list A and B. The list 'A' contains a column 'Access to' which is of type 'Person and Group' ( Multiple is possible ). I want to change the item permission of list 'B' to the selected value in list A's 'Access to' column.

Guide me how to do this.

Was it helpful?

Solution

SPWeb web = SPContext.Current.Web;
SPGroup oGroup = web.Groups.GetByID   (oFieldUserValue.LookupId);   //Look up field value                                     
SPPrincipal principal = (SPPrincipal)oGroup;
SPRoleAssignment roleAssignment = new SPRoleAssignment(principal);                                        
permFolder.Item.BreakRoleInheritance(true);                                        
roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions["Contribute"]);
permFolder.Item.RoleAssignments.Add(roleAssignment);
permFolder.Item.Update();
finalItem.Update();  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top