Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

Object reference not set error when setting specialPermissions in createtask activity for sequential workflow

$
0
0

Hi,

I am trying to use the SpecialPermissions in CreateTask Activity. I am trying to set the custom role. The custom role exists in the site.

I have tried the below code:

private void createTaskforApprover_MethodInvoking(object sender, EventArgs e)
 {
 this.ApproverTaskId = Guid.NewGuid();
 CreateTask taskForApprover = sender as CreateTask;
using (SPSite oSite = new SPSite(workflowProperties.SiteId))
            {
                using (SPWeb oWeb = oSite.OpenWeb(workflowProperties.WebId))
                {
                    oWeb.AllowUnsafeUpdates = true;
                    SPRoleDefinition oSPRoleDefinition = oWeb.RoleDefinitions["customRoleName"];
                    taskForApprover.SpecialPermissions.Add("domain\userloginname, oSPRoleDefinition);
                    oWeb.AllowUnsafeUpdates = false;
                }
            }
}

There is value in the oSPRoleDefinition. I am getting the object reference  error in the SpecialPermissions.Add.

How to fix this? How to add the custom role in special permissions?

Thanks


Viewing all articles
Browse latest Browse all 11508

Trending Articles