How to retrieve Worklist item using the .GetWorklistItems(filter) of Management API?

  • 6 January 2011
  • 3 replies
  • 3 views

Badge +1

Hi Everyone,


I am trying to get all of the Worklist items from a K2 server using a ProcInstID and ActInstDestID.


How can I do this using the API?


 


Thanks.


3 replies

Badge +8

I don't think there's a direct way to query it, but if you know the Destination user, it can be quite simple. Sample code below:



WFM.WorkflowManagementServer wfmServer = new SourceCode.Workflow.Management.WorkflowManagementServer();


            int iProcInstID = 10,


                iActInstID = 11;


            try


            {


                wfmServer.CreateConnection();


                wfmServer.Connection.Open("Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=blackpearl;Port=5555");


 


                WFM.Criteria.WorklistCriteriaFilter oFilter = new SourceCode.Workflow.Management.Criteria.WorklistCriteriaFilter();


 


                oFilter.AddRegularFilter(WFM.WorklistFields.Destination, SourceCode.Workflow.Management.Criteria.Comparison.Equals, "K2:DenallixAnthony");


 


                WFM.WorklistItems oItems = wfmServer.GetWorklistItems(oFilter);


 


 


                foreach (WFM.WorklistItem oItem in oItems)


                {


                    if (oItem.ProcInstID == iProcInstID &&


                        oItem.ActInstDestID == iActInstID)


                        wfmServer.RedirectWorklistItem("UserA", "UserB",


                            oItem.ProcInstID, oItem.ActInstDestID,


                            oItem.ID);


                }


 


            }


            finally


            {


                if (wfmServer.Connection != null && wfmServer.Connection.IsConnected)


                    wfmServer.Connection.Close();


            }


Badge +1

Hi dc,


Given that I can readily get these items, can I delete the process or stop it to prevent it from showing in the worklist report?


Thanks.

Badge +8

Yes, have a look at the WorkflowManagementServer object in the Help File, it has methods to Stop and Delete instances. 

Reply