Get a list of all process instances by datafield

  • 14 July 2006
  • 9 replies
  • 20 views

Badge +2
I need to retrieve a list of all process instances from K2 with a particular datafield set to a specific value, for example all processes where the "Ref" field equals 100.

This should be regardless of the user that the instance is assigned to and regardless of the user that's logged on.

Anyone have any ideas? This must be done programatically through the K2ROM or any of the other dlls provided.

Thanks, Steve

9 replies

Badge +13
I have the same need, and also to be able to filter on if workitem is completed or not.
Badge +2
It seems the best way to do this is using the FilterService web service.

There's an article about it and an example application in the knowledgebase.
Badge +3

I have the same need, but for Blackpearl.  I'm not finding the filter service in Blackpearl, so any ideas there?  Also, what's the link to the KB?  I don't believe I have that either.

 

Thanks,

Jason 

Badge +1

I'm also looking for that. Any ideas?

What about the List Process Instances method?

 

 

Badge +3

I seem to recall solving this issue in black pearl by using the list all instances and adding a filter in code to only return where datafield x = y.  I don't have the code (previous employer), but I'll see if I can look it up and post back to the forum.

 Good luck.

Badge +1

Here is what i've got in my case:

SmartObjectClientServer SmOServer = new SmartObjectClientServer();

            SmOServer.CreateConnection();

            SCConnectionStringBuilder cb = new SCConnectionStringBuilder();
            cb.Host = "DLX";
            cb.Port = 5555;
            cb.Integrated = true;
            cb.IsPrimaryLogin = true;
            SmOServer.Connection.Open(cb.ToString());

            SmartObject mySmO = SmOServer.GetSmartObject(@"Rpt_K2WorkflowProject1_RequestProcess");
            SmartListMethodCollection slmc = mySmO.ListMethods;
            SmartListMethod getList = slmc["ListProcessInstances"];
            mySmO.MethodToExecute = getList.Name;
            Equals filter = new Equals(
                new PropertyExpression("Folio", PropertyType.Text),
                new ValueExpression("Sales order 15", PropertyType.Text));
            getList.Filter = filter;

            SmartObjectList sol = SmOServer.ExecuteList(mySmO);

 

But when this is executed in a server event my smartobjectlist is empty.

When executed from an aspx page, my smartobjectlist is filled as i want it to be.

???

 

Badge +1

Well now it seems to work. don't know what happened.

 

Badge +11

Hi 


Below are the GetWorklistItems methods of the WorkflowManagementServer object


which is part of the

SourceCode.Workflow.Management. 


WorklistItems GetWorklistItems(WorklistCriteria wl);


WorklistItems GetWorklistItems(WorklistCriteriaFilter filter);


WorklistItems GetWorklistItems(DateTime fromDate, DateTime toDate, string destination, string processName, string activityName, string eventName, string folio);


WorklistItems GetWorklistItems(string destination, string processName, string activityName, string eventName, string folio, string fromDate, string toDate);


.


You can use the first two methods to filter and return results


 


below is an example in asp.net


using

SourceCode.Workflow.Management;//dont forget the using part


WorkflowManagementServer wms = new WorkflowManagementServer("servername", 5555);


wms.Open();


string procSet = "k2:Domaink2Adminstrator";

WorklistItems wi = wms.GetWorklistItems(DateTime.MinValue, DateTime.MaxValue, procSet,"%", "%", "%", "%");

Badge +11

This is an example of a filter on a datafield called  SubjectMatterExpert that has the value aa


 


//Open Connection


Connection conn = new Connection();


conn.Open("SERVER");


//Get Worklist for current Logged on User


WorklistCriteria wlc = new WorklistCriteria();


wlc.AddFilterField(

WCLogical.And, WCField.ProcessData, "SubjectMatterExpert", WCCompare.Equal, "aa");


Worklist wl;


wl = conn.OpenWorklist(wlc);


 


//create a data table


DataTable dt = new DataTable();


//add some columns


dt.Columns.Add(

"SerialNumber");


dt.Columns.Add(

"ProcessName");


dt.Columns.Add(

"ActivityName");


dt.Columns.Add(

"EventName");


dt.Columns.Add(

"StartDate");


dt.Columns.Add(

"Folio");


 


foreach (WorklistItem wli in wl)


{


//create a new row, with columns defined


DataRow dr = dt.NewRow();


//add values from worklist + sub-objects


dr["SerialNumber"] = wli.SerialNumber;

dr[

"ProcessName"] = wli.ProcessInstance.FullName;


dr[

"ActivityName"] = wli.ActivityInstanceDestination.Name;


dr[

"EventName"] = wli.EventInstance.Name;


dr[

"StartDate"] = wli.EventInstance.StartDate.ToString();


dr[

"Folio"] = wli.ProcessInstance.Folio;


//add the data row to the data table


dt.Rows.Add(dr);


}


//bind data table to grid


gridViewWorklistItems.DataSource = dt;


gridViewWorklistItems.DataBind();

Reply