Rahul Khanna

Rahul Khanna

  • NA
  • 236
  • 0

Remove permission for old task owner in approval workflow

Nov 30 2014 5:19 AM
I am programmatically delegating task to another user for a Nintex approval workflow. For example actual approver is "DOMAIN\Test1". And the delegated user is "DOMAIN\Test2"; Using the below code its delegating the task to "DOMAIN\Test2" user but the problem is still the actual approver "DOMAIN\Test1" retain the permission to complete the task, I mean "DOMAIN\Test1" still is able to click the "Complete Task" button, actually this button should be hidden for him("DOMAIN\Test1"). How can I do this?


  using (SPSite currentSite = new SPSite("http://tst:001/sites/Test"))
{
using (SPWeb currentWeb = currentSite.OpenWeb())
{
string tasksList = "Workflow Tasks";
SPUser delegateTouser = currentWeb.EnsureUser("DOMAIN\\Test2");
SPListItem listItem = currentWeb.Lists.TryGetList(tasksList).GetItemById(101);
listItem[SPBuiltInFieldId.AssignedTo] = delegateTouser;
listItem[SPBuiltInFieldId.WorkflowVersion] = "1";
listItem.Update();
}
}