Hi I am trying to close off any tasks not finished by users when a workflow ends, We have reached the point where the item is opened, but no matter what options we've tried in terms of sequence to open and / or impersonate the user we can't get it to work. If we use a console app with essentially the same code it does correctly close off tasks. So below is the console code: Any ideas on why it works in a console but not in the code in the Server Event?
Connection oConn = new Connection();
oConn.Open("ServerName");
WorklistItem master = oConn.OpenWorklistItem("theItemID", "ASP", false);
string targettedUser = master.DelegatedUserse0].Name;
master =
null;
oConn.ImpersonateUser(targettedUser);
WorklistItem oWli = oConn.OpenWorklistItem("theItemID");
oWli.Actionso
"Processed"].Execute();
oConn.RevertUser();
oConn.Close();
oConn.Dispose();