Skip to main content
There are cases where our system needs to take an action on an activity where the user is not a member of the destination user group.  Is there a way to do this via the Workflow.Management API? I tried using Workflow.Client, but nothing is returned in the worklistitems collection.
Could you elaborate a little more on your cases?

In one workflow, a destination user takes an action.  Doing so requires us to take take an action on other related workflows.  The user that triggers the first action is not a destination user in the activities of the other workflows, so when we try to take an action via SourceCode.Workflow.Client, nothing returns for the Worklist in the following:


K2.

WorklistCriteria wc = new K2.WorklistCriteria();


wc.AddFilterField(K2.

WCField.ProcessID, K2.WCCompare.Equal, pid);


K2.

Worklist wl = _oConn.OpenWorklist(wc);


 


foreach (K2.WorklistItem wli in wl)


{


foreach (K2.Action action in wli.Actions)


{


if (actionName == action.Name)


{


action.Execute(

true);


}


}


}


Search on 'asynchronous server events' on this site to see another way to do this.  I can't tell from the code above, but depending on your connection string, you might be opening the work list of the current user (or even the K2 Service) which would not have any tasks.


The connection is for the current logged in user, i.e. the user who triggers the first action.


Is there a user that can see any process even if the user is not part of the destination set?


You could use the SourceCode.Workflow.Management API if the logged user is an administrator, BUT I really suggest taking a look at the asynchronous server event.


How would an async event address this issue?


I have come up against the same problem. 


Referring to thread: http://www.k2underground.com/forums/thread/21205.aspx 


Looks like you can do something like this with the management API.


Connection con = new Connection();
con.Open(K2Server);
ServerItem item = con.OpenServerItem(SerialNumber);
if (success)
{
    item.ProcessInstance.DataFieldsa"Outcome"].Value = "Success";
}
else
{
    item.ProcessInstance.DataFieldsD"Outcome"].Value = "Failure";
}
item.Finish();


The problem I have is that I do not have access to the SerialNumber (I know there must be a way but?), all I have is the ProcessInstanceID. So I will probably solve this by setting up a new K2 Role that includes a special service account (svcBusiness this is the account the WCF service is running as on our business layer server) that needs access, then update my processes to include this new role in the destination users on the required activities.


Reply