Programmatically get all the work list items for manager

  • 3 September 2009
  • 8 replies
  • 7 views

Badge +4

Hi,


I have a query: How to get all the worklist items for a manager and all the employes's working under him? 


Manager and his subordinate hiearchy details are maintained in custom database. but Manager hierarchy details are not maintained in the active directory.  programmatically how to open the worklist item by passing managerid and list of employess's working under him?


Can somebody suggest best way to implement this?


Thanks,


-Nithya


8 replies

Badge +2

Hi Nithya,

You can use the global worklist to access all items and then filter based on your list of people. This will require the user to have admin server rights in K2.

I've created an example at http://codepaste.net/jy6wdx.

Let me know how you go.

Badge +4

Hi Shane Stevenson,


Thanks for your reply.


I tried your code snippet and am getting the following exception in this line:::


SourceCode.Workflow.Management.

WorklistItems allWorklistItems = workflowManagementServer.GetWorklistItems("", "", "", "", "", "", "");


Error Message:  SerializationException was unhandled by user code: "The ObjectManager found an invalid number of fixups. This usually indicates a problem in the Formatter."


 Could you please help me out?


-Nithya


 

Badge +2

Hi Nithya,


Try different overloads of GetWorklistItems() and also have a read of the 'How to access and return information from the Global Worklist' article in the K2 documentation.


If you still get the exception, please post the stack trace and sample code if possible. It'll help narrow down the issue.

Badge +4

Hi Shane Stevenson, 


Thanks for your quick response. I am getting the same exception.  


Below is the sample code which i tried:


using

System;


using

System.Collections.Generic;


using

System.Linq;


using

System.Web;


using System.Web.UI;


using

System.Web.UI.WebControls;


using

SourceCode.Workflow.Management;


using

SourceCode.Hosting.Client.BaseAPI;


using

SourceCode.Workflow.Management.Criteria;


namespace

GlobalWorklist


{


public partial class _Default : System.Web.UI.Page


{


protected void Page_Load(object sender, EventArgs e)


{


string[] strNames = new string[] {"DomainUserID1", "DomainUserID2"};


GetStaffWorklistItems(strNames);


}


private SourceCode.Workflow.Management.WorklistItem[] GetStaffWorklistItems(string[] staff)


{



WorkflowManagementServer workflowManagementServer = new WorkflowManagementServer();


workflowManagementServer.CreateConnection();


string connectionString = "Integrated=True;IsPrimaryLogin=True;Authenticate=True;Host=localhost;Port=5555";


SCConnectionStringBuilder connectionBuilder = new SCConnectionStringBuilder(connectionString);


workflowManagementServer.Connection.Open(connectionBuilder.ToString());



try


{


WorklistItems

allWorklistItems = workflowManagementServer.GetWorklistItems("", "", "", "", "", "", "");


List<SourceCode.Workflow.Management.WorklistItem> filteredWorklistItems = new List<SourceCode.Workflow.Management.WorklistItem>();


foreach (string staffName in staff)



{


filteredWorklistItems.AddRange(allWorklistItems


.Cast<SourceCode.Workflow.Management.

WorklistItem>()


.Where(worklistItem => worklistItem.Destination == staffName));


}


return filteredWorklistItems.ToArray();


}


finally


{ workflowManagementServer.Connection.Close(); }



 }


   }


}


Exception Message:The ObjectManager found an invalid number of fixups. This usually indicates a problem in the Formatter


Stack Trace :


   at SourceCode.Workflow.Management.WorkflowManagementServer.GetWorklistItems(String destination, String processName, String activityName, String eventName, String folio, String fromDate, String toDate)


Note: using K2 BlackPearl 0807 version 4.8210.3.0, Microsoft Visual Studio 2008


Could you please help me out?


 -Nithya 


 


 


 

Badge +2

Hi,

I cannot reproduce the issue. Maybe a particular worklist item is causing the issue. Can you try deleting all process instances so that the global worklist is empty and then try the code again?

Or maybe the parameters are causing a problem. Try:

WorklistItems allWorklistItems = workflowManagementServer.GetWorklistItems(new WorklistCriteria());

instead of

WorklistItems allWorklistItems = workflowManagementServer.GetWorklistItems("", "", "", "", "", "", "");

Badge +4

Hi Shane Stevenson,


Thanks for your help. I tried the same code in differnet server, It's working fine.


Please bare with me. Just one more question. Global worklist contains Process Name, Folio, Event Name, Activity Name, Destination, Process Instance Status,etc..How can i fetch the Datafield and XML field values from the global worklist?  


-Nithya 


 

Badge +2

Good to hear!

I haven't used this but it looks like workflowManagementServer.GetProcessDataFields() will do the trick. There is a similar method for xml fields.

 Edit: Maybe not afterall. You'll need to open a normal SourceCode.Workflow.Client.Connection and use the OpenProcessInstance() method. From there you can access DataFields and XmlFields.

Badge +13

For small sets of open worklist items this might be ok but not going to scale when it has 5,000 or more work items....you'll need to loop through more and more items just to get what you need.

Is there a SmartObject that filters on the destination user instead, or can go direclty with SQL to pull procInstID and open that directly?

Reply