Skip to main content
Nintex Community Menu Bar

Using filter criteria for WorklistItemOwner "Other" throw an exception

  • December 18, 2015
  • 0 replies
  • 8 views

Forum|alt.badge.img+15


 

Symptoms


Trying to get worklists items with the following criteria:
criteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null)
foreach (string process in processName)
{
criteria.AddFilterField(WCLogical.Or, WCField.ProcessFullName, WCCompare.Equal, "PaymentVoucher"" process)
}
criteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null)
criteria.AddFilterField(WCLogical.And, WCField.WorklistItemStatus, WCCompare.Equal, 0) // Open
criteria.AddFilterField(WCLogical.Or, WCField.WorklistItemStatus, WCCompare.Equal, 1) // Available
criteria.AddFilterField(WCLogical.And, WCField.WorklistItemOwner, "Me", WCCompare.Equal, WCWorklistItemOwner.Me)
criteria.AddFilterField(WCLogical.Or, WCField.WorklistItemOwner, "Other", WCCompare.Equal, WCWorklistItemOwner.Other)

Throw the following exception when calling method "OpenWorklist(criteria)"
Incorrect syntax near ')'.

By removing the line "criteria.AddFilterField(WCLogical.Or, WCField.WorklistItemOwner, "Other", WCCompare.Equal, WCWorklistItemOwner.Other)"
the codes run just fine. Are there any rules missing?


 

Diagnoses


The error seems to come from the following line:

criteria.AddFilterField(WCLogical.StartBracket

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

Removing the above 2 lines will allow the snippet to run but will not return the results the user is expecting.
 

Resolution

The following snippet resolve the issue:

WorklistCriteria criteria = new WorklistCriteria()
foreach (string process in processName)
{
if (criteria.Filters.Length == 0)
criteria.AddFilterField(WCLogical.And, WCField.ProcessFullName, WCCompare.Equal, "PaymentVoucher"" process)
else
criteria.AddFilterField(WCLogical.Or, WCField.ProcessFullName, WCCompare.Equal, "PaymentVoucher"" process)
}
criteria.AddFilterField(WCLogical.And, WCField.WorklistItemStatus, WCCompare.Equal, 0) // Open
criteria.AddFilterField(WCLogical.Or, WCField.WorklistItemStatus, WCCompare.Equal, 1) // Available
criteria.AddFilterField(WCLogical.And, WCField.WorklistItemOwner, "Me", WCCompare.Equal, WCWorklistItemOwner.Me)
criteria.AddFilterField(WCLogical.Or, WCField.WorklistItemOwner, "Other", WCCompare.Equal, WCWorklistItemOwner.Other)