Skip to main content

Hi, I am trying to get  worlist using

 worklist = cnn.OpenWorklist(criteria);

 

The criteria is  to get worklist items with ( (Status=0 or Status=1) and Owner=Me)  or ( Status=0 and Owner=Other).

I tried something below.

                   criteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null);
                    criteria.AddFilterField(WCLogical.StartBracket, WCField.WorklistItemStatus, WCCompare.Equal, 0);
                    criteria.AddFilterField(WCLogical.Or, WCField.WorklistItemStatus, WCCompare.Equal, 1);
                    criteria.AddFilterField(WCLogical.AndBracket, WCField.WorklistItemOwner, "Me", WCCompare.Equal, WCWorklistItemOwner.Me);
                    criteria.AddFilterField(WCLogical.Or, WCField.None, WCCompare.Equal, null);
                    criteria.AddFilterField(WCLogical.StartBracket, WCField.WorklistItemOwner, "Other", WCCompare.Equal, WCWorklistItemOwner.Other);
                    criteria.AddFilterField(WCLogical.AndBracket, WCField.WorklistItemStatus, WCCompare.Equal, 0);
                    criteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null);

 

I get an exception  Incorrect syntax near ')'.

After some reading on google, I found that 

criteria.AddFilterField(WCLogical.StartBracket, WCField.WorklistItemOwner, "Other", WCCompare.Equal, WCWorklistItemOwner.Other);

doesnt not ork if the criteria is using the lines

  criteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null);

criteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null);.

 

Id ont understnd the relation between these peices of code. but when I remove the above lines, WCWorklistItemOwner.Other works fine. Is this a design flaw/bug with K2 API.

 

Can some one help me achive the criteria ( (Status=0 or Status=1) and Owner=Me)  or ( Status=0 and Owner=Other)

Hello AmarnathPoosala,


 


Did you find an answer to your question?


 


We have detailed information on the Open.Worklist with criteria: https://help.k2.com/onlinehelp/k2blackpearl/DevRef/4.7/default.htm#Retrieving_the_worklist_with_criteria.html


 


Hi AmarnathPoosala,

     

Use below code for filtering

 

// ( (Status=0 or Status=1) and Owner=Me) or ( Status=0 and Owner=Other).

 

K2Crit.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null);//(
K2Crit.AddFilterField(WCLogical.StartBracket, WCField.WorklistItemStatus, WCCompare.Equal, 0);//( status=0
K2Crit.AddFilterField(WCLogical.Or, WCField.WorklistItemStatus, WCCompare.Equal, 1);// or status=1
K2Crit.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Like, "");//)
K2Crit.AddFilterField(WCLogical.And, WCField.WorklistItemOwner, "Me", WCCompare.Equal, WCWorklistItemOwner.Me);// and WorklistItemOwner="me"
K2Crit.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Like, "");// )

K2Crit.AddFilterField(WCLogical.Or, WCField.None, WCCompare.Like, "");// or

K2Crit.AddFilterField(WCLogical.StartBracket, WCField.WorklistItemStatus, WCCompare.Equal, 0);//( WorklistItemStatus=0
K2Crit.AddFilterField(WCLogical.And, WCField.WorklistItemOwner, "Other", WCCompare.Equal, WCWorklistItemOwner.Other);// and WorklistItemOwner="Other"
K2Crit.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Like, "");//)

 

 

 

Let me know if this helps you.


Reply