How to filter my returned process instances based on priority of the process instance (Criteria.ProcessInstanceCriteriaFilter)

  • 6 December 2010
  • 4 replies
  • 4 views

Badge +2

 


Hello,


 


I am working on code that get process instances based on specific predefined search criteria using Management API:


 


Dim processInstanceCriteriaFilter As Criteria.ProcessInstanceCriteriaFilter = New Criteria.ProcessInstanceCriteriaFilter()


 


processInstanceCriteriaFilter.AddRegularFilter(ProcessInstanceFields.ProcInstID, Criteria.Comparison.Like, procId.ToString())


 


 


and it is works fine, but I need to add filter related to “Priority”  which is unfortunately  not exist as Enum in “ProcessInstanceFields”


 


Please advice.



Regards,


4 replies

Badge +5

Hi Huda Al-Masoud,


Did you manage to get past this issue?  Why not use the SourceCode.Workflow.Client Namespace, WorklistCriteria class?


Regards,
Frikkie!

Badge +2

Hi,


Thank you I already done from this issue, I found  way to solve it using Criteria.ProcessInstanceCriteriaFilter.


regards,

Badge +11

Can you share this with us, i am going through this issue too.


 i want the tasks with the highest priority come first regardless of their date

Badge +2

Hi,


 


I wrote the below code, for sure you need to change it according to your need:


 


 


Dim arrPriority As String() ......  ' use this to store the priority/ priorities you select

 



 


Dim regularFilter As New SourceCode.Workflow.Management.Criteria.RegularFilter()

 



 


Dim workflowPriorityValue As WorkflowPriority ' I put the priorities  as enum in this class


regularFilter.ColumnName =  "[PI].Priority"  ' [tableName].ColumnName ... note that PI is the name of the table that the k2 create when it used its generated sp to handle this type of filtration you should not care about the SP it will be generated by itself


regularFilter.DbType = DbType.String

 


regularFilter.Comparison = Criteria.Comparison.Like



 



 


 ' handle selection for one priority


If (arrPriority.Length = 1) Then



 



regularFilter.ParameterName =



"@WORKFLOW_PRIORITY"  ' you can use any parameter name this will be used in genrated SP.


workflowPriorityValue = [Enum].Parse(GetType(WorkflowPriority), arrPriority(0), True)



 


Else





' Handel the selection for two priorities




regularFilter.ParameterName =





 



"@WORKFLOW_PRIORITY"



workflowPriorityValue = [Enum].Parse(



GetType(WorkflowPriority), arrPriority(0), True)





 


Dim regularFilter2 As New


SourceCode.Workflow.Management.Criteria.RegularFilter()

regularFilter2.ColumnName =



"[PI].Priority"


 




regularFilter2.ParameterName =



"@WORKFLOW_PRIORITY2"



workflowPriorityValue = [Enum].Parse(



GetType(WorkflowPriority), arrPriority(1), True)




 


End If


Note:


This code is used to handle selection for one ot two different priorities from "High, Medium, low". becuase in my case if I select none or all priorities  type I must return all tasks like I did not do any filtration. So I handle the selection of only one or two priorities.


Regards,


Huda Al Masoud

Reply