K2 Search API CSharp Code

  • 16 November 2011
  • 3 replies
  • 0 views

Badge +2

Hi All,


I created a workitem through CSharp API. It is working fine. After I created the workitem i want to search the workitem throuch CSharp API code.


During the work item creation, I am setting some alpha numeric value(eg : 17457acf-e60a-e111-9ed6-00155d50c10b) to Folio data field.


The following code I am using to search the woek item in the K2 server.


 WorklistCriteria workListCriteria = new WorklistCriteria();


Worklist workList;

workListCriteria.AddFilterField(



 



 


WCField.ProcessFullName,WCCompare.Like,SPA_Demo1Demo1);


workListCriteria.AddFilterField(





 



WCField.ProcessFolio, WCCompare.Like, "17457acf-e60a-e111-9ed6-00155d50c10b");



 



workList = conn.OpenWorklist(workListCriteria);

SPA_Demo1 is the Project name and Demo1 is the Workflow name.


After running this program I am not getting any workitem in the workList object, the count is always zero. But I can able to see the workitem in the K2Workspace Instance window.


Please help me to resolve this issue.



3 replies

Badge +8



 


Since you have multiple fields used for filtering, you will need to provide the logical comparison for the two. I.e.


 


workListCriteria.AddFilterField(WCLogical.AndBracket, WCField.ProcessFullName, WCCompare.Like, "SPA_Demo1Demo1");


workListCriteria.AddFilterField(WCLogical.EndBracket, WCField.ProcessFolio, WCCompare.Like, "17457acf-e60a-e111-9ed6-00155d50c10b");



 



Badge +2

Thanks for your reply,


I tried by using the same code snippet you suggested, but still facing the same issue.


Regards,


-Balaji. S

Badge +8

Then I would validate the input values. The code sample gave me the results I wanted.


I would start by executing single filters at a time, that's the easiest to validate that there are no typo's in the filter values. Then, start doing Or's instead of And's. 

Reply