I currently need to delegate a Nintex 2010 Flexi Task to another user in C# server code. I currently have tried using this code snippet to do this, but the result is always false (unsuccessful).
public bool DelegateTask(SPListItem taskItem, SPUser delegateToUser)
NintexTask nintexTask = NintexTask.RetrieveTask(taskItem.ID, taskItem.Web, taskItem.ParentList);
Approver approver = nintexTask.Approvers.GetBySPId(taskItem.ID);
bool success = Delegation.DelegateApprovalTask(true, approver, delegateToUser.LoginName, false, false, "Delegated note.",true);
Delegation is turned on for the Flexi Task, and I can do it from the Nintex Form manually. Maybe Delegation.DelegateApprovalTask doesn't work for Flexi Task delegations? Could I just change the Assigned To on the task and achieve the same result? Any help would be appreciated.
delegation doesn't even need to be turned on for the task if you are an administrator. This checkbox only allows/disallows delegation for regular users. Yes you could just change the "Assigned To" field, but that doesn't effect the actual assignee, it may display another user in the field but he/she still won't be able to respond to this task.
I can't see anythin wrong in your code. Can you check ULS Log at the time of execution? Maybe we get some error code there.
Sorry for the delayed follow up to this. I had to put this on hold due to other issues. The code appears to be working now... I think the issue was possibly the wrong task being passed into the method. Thanks for the help Philipp. I was about to check the ULS logs next.