Completing a worklist item using the API


Badge +1

This line of code is not working:  oItem.Status = WorklistItem.WorklistStatus.Completed;

Any ideas what is wrong with it? The code reaches that line, but the oItem does not actually get completed.

I am calling this from within a k2 process instance.

I want to automatically complete any events "Form - Input" with the same folio as the existing process.

 

 

 

 

WorkflowManagementServer wfmServer = new SourceCode.Workflow.Management.WorkflowManagementServer();
                try
                {
                    wfmServer.CreateConnection();
                    wfmServer.Connection.Open("Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=blackpearl;Port=5555");
                    WorklistCriteriaFilter oFilter = new WorklistCriteriaFilter();
                    oFilter.AddRegularFilter(WorklistFields.Folio, Comparison.Equals, K2.ProcessInstance.Folio);
                    oFilter.AddRegularFilter(WorklistFields.EventName, Comparison.Like, "Form - Input");
                    WorklistItems oItems = wfmServer.GetWorklistItems(oFilter);

                    foreach (WorklistItem oItem in oItems)
                    {
                        oItem.Status = WorklistItem.WorklistStatus.Completed;
                    }
                }

                finally
                {
                    if (wfmServer.Connection != null && wfmServer.Connection.IsConnected)
                        wfmServer.Connection.Close();
                }


4 replies

Badge +5

Hi Valerie,

 

I assume you are trying to auto-complete the assigned tasks? If yes, you should be executing the actions on the worklist item.

 

WorklistItem.Actions["<the action name>"].execute()

 

 

JK

Badge +7

Hi Valerie,


 


Please see the attached document which will cover how the SourceCode.Workflow.Client assembly is often used to create custom task lists, to start workflows or complete workflow tasks (knows as worklist items) from custom user interfaces like ASP.NET web pages, and to create alternative interfaces or tools to allow users to maintain their out-of-office status and worklist items.


The workflow client is also often used to create automated testing code or applications that are executed against a
workflow definition to verify that the workflow is behaving as expected.


 


I hope this help.


 


Kind regards


Nelly

Badge +1

From what I can tell, SourceCode.Workflow.Client only works with the current user's items. I need all items.

 

SourceCode.Workflow.Management doesn't seem to have Actions["Complete"].Execute()

 

I need to get all worklist items for everyone & complete them. Any other ideas?

Badge +8

You can't complete worklist items that way.

 

The SourceCode.Workflow.Client namespace allows you to impersonate a user via the Connection.ImpersonateUser() method.  You should impersonate the user to whom the task is assigned and complete worklist items that way.

 

You can use the SourceCode.Workflow.Management namespace to get a list of all worklist items and the user to whom they are assigned if needed.

Reply