Break Role Inheritance and add custom role to current item in visual studio 2012 workflow

Hi,

How to break the role inheritance and add custom users/groups to current item in List using workflow in VS 2012?

In earlier VS 2010 Workflow, the coding was there to do the same. But how to achieve it in VS 2012 workflow?

Thanks

January 10th, 2014 10:29am

Hi,

According to your post, my understanding is that you wanted to break Role Inheritance and add custom role to current item in visual studio 2012 workflow.

I recommend to use the below code within workflow:

SPGroup securityGroup = spWeb.SiteGroups["Security Group Name"];  
SPRoleDefinition groupRole = spWeb.RoleDefinitions["Read"];    
SPRoleAssignment roleAssign = new SPRoleAssignment(securityGroup);  
roleAssign.RoleDefinitionBindings.Add(groupRole);   
SPListItem listItem = spWeb.GetListItem("http://List Item URL");  
listItem.BreakRoleInheritance(true);  
listItem.RoleAssegnments.Add(roleAssignment);  
listItem.Update();

Here is a similar thread for you to take a look at:

http://blog.sharepointclick.com/2013/04/programatically-breaking-inheritance.html

Best Regards,

Linda Li

Free Windows Admin Tool Kit Click here and download it now
January 13th, 2014 3:30am

HI,

Thanks for the reply.

How to use the code in VS 2012 workflow. I have used the role inheritance break in VS 2010 for SharePoint 2010, but I am not sure how to use in VS 2012 workflow for SharePoint 2013. In VS 2012, the workflow is of "xaml" type.

Thanks


January 13th, 2014 3:35am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics