WCF filter on workitemstatus

  • 20 September 2013
  • 3 replies
  • 1 view

Badge +4

I am creating my own workitem list using the WCF K2 Service.  I noticed when I call OpenWorkList I'm getting duplicate entries for one task, one being Open and the other being Allocated.  I assume this is normal stuff behind the scenes.  So I'm trying to filter the list by using the CriteriaFilter.  I'd like only those that are Open and Available.  I'm using the code below however I'm gett an Invalid cast .Net error.  I don't see any examples out there for filtering on status.  any ideas?


 


 


 


 


 


 



 



 



 


Criteria criteria = new Criteria()

{



Filter =



 



new[]{

 



 



 


new CriteriaFilter()

{



Field =



 



CriteriaField.WorklistItemStatus,

Comparison =



 



CriteriaComparison.Equal,

Value =



 



"Available"



}



3 replies

Badge +6

All items will show if you don't have right filters. It is expected. Please see the default filters that are set on workspace worklist to get an understanding.


WCF Filtering example
-------------------------------
WcfK2Services.WorklistNavigationServiceClient client = new WcfK2Services.WorklistNavigationServiceClient();
            WcfK2Services.Criteria criteria = new WcfK2Services.Criteria()
            {
                Filter = new []
                {
                    new WcfK2Services.CriteriaFilter()
                    {
                        Field = WcfK2Services.CriteriaField.ProcessFolio,
                        Comparison = WcfK2Services.CriteriaComparison.Equal,
                        Value = "Approve Customer",
                        ValueType = WcfK2Services.ValueType.String
                    },
                    new WcfK2Services.CriteriaFilter()
                    {
                        Logical = WcfK2Services.CriteriaLogical.And,
                        Field = WcfK2Services.CriteriaField.ProcessData,
                        SubField = "Customer Name",
                        Comparison = WcfK2Services.CriteriaComparison.Like,
                        Value = "*Mary*",
                        ValueType = WcfK2Services.ValueType.String
                    }
                },
                Sort = new []
                {
                    new WcfK2Services.CriteriaSort()
                    {
                        Field = WcfK2Services.CriteriaField.ProcessStartDate,
                        Order = WcfK2Services.CriteriaSortOrder.Ascending
                    }
                }
            };
            WcfK2Services.WorklistItem[] items = client.OpenWorklistFiltered(criteria, false, false, false, false);

Badge +4

Right, I'm with ya.  So I'm trying to code those defaults.  My issue is that the examples, including your example, so comparisons against simple string fields.  I cannot get the comparison for status to work.  If I compare CriteriaField.status to "Open", is gives me a casting error.  If I compare CriteriaField.status to WorkItemStatus.Open, I get the same error.  So I'm trying to figure out the code snippet to compare status so that I only get Open and available.  In the meantime, I'm getting everything then looping through.

Badge +6

try this:


SourceCode.Workflow.Client.Connection _ConClient = new SourceCode.Workflow.Client.Connection();
_ConClient.Open("Localhost");
SourceCode.Workflow.Client.WorklistCriteria _workCriteria = new SourceCode.Workflow.Client.WorklistCriteria();
_workCriteria.AddFilterField(SourceCode.Workflow.Client.WCField.WorklistItemStatus, SourceCode.Workflow.Client.WCCompare.Equal, "Open");  
_workCriteria.AddFilterField(SourceCode.Workflow.Client.WCLogical.NONE, SourceCode.Workflow.Client.WCField.WorklistItemStatus, SourceCode.Workflow.Client.WCCompare.Equal, "Available");  

Reply