Increase an activity’s priority and expire the task when it reaches a certain priority

  • 24 February 2022
  • 0 replies
  • 58 views

Userlevel 3
Badge +8
 

Increase an activity’s priority and expire the task when it reaches a certain priority

KB000024

DOWNLOADS
DOWNLOADS
PRODUCT
K2.net 2003
LEGACY/ARCHIVED CONTENT
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.

There is no escalation rule that will increase an activity’s (or process's) priority. This is easily achieved by writing an escalation rule that will increase the priority every time it fires.

 

The screenshot below illustrates a process that has an escalation called “Increase Priority”. This fires every 10 seconds for 3 times. After the third time, the FeedbackPriority reaches “High”, and the process continues, following the “high priority” path.  
 
 
The code snippet below was taken from the escalation action and illustrates the priority increase for the activity.
Sub Main(ByVal K2 As EscalationActionContext)
  ' Meaning for K2.ActivityInstance.Priority
  ' 0 = High
  ' 1 = Medium
  ' 2 = Low

  ' Is this the first time this escalation fires?
  ' We know this is the first time because the initial
  ' value for the FeedbackPriority
  ' DataField is set to -1

  If K2.ProcessInstance.DataFields.Item("FeedbackPriority").Value <> "-1" Then
    ' By decreasing the priority integer value every time,
    ' the escalation action fires, the priority
    ' increases from ‘Low’ to ‘Medium’ to ‘High’.
    If K2.ActivityInstance.Priority > 0 Then
      K2.ActivityInstance.Priority -= 1
    End If
  End If

  ' Store the new priority property in a process-level data field
  K2.ProcessInstance.DataFields.Item("FeedbackPriority").Value = _
  GetPriorityText(K2.ActivityInstance.Priority)
  If K2.ActivityInstance.Priority = 0 Then
    ' Once the activity has reached a "High" priority,
    ' let’s expire this activity and
    ' continue with the process along the ‘High Priority’ path
    K2.ExpireActivity("Feedback")
    
    ' NOTE: This escalation was set to fire at most,
    ' three times, meaning, fire the escalation
    ' after 10 seconds and then repeating it two times
    ' thereafter (every 10 seconds).
  End If
End Sub
Private Function GetPriorityText(ByVal Priority As Integer)
  Select Case Priority
    Case 0 : Return "High"
    Case 1 : Return "Medium"
    Case 2 : Return "Low"
  End Select
End Function

 


0 replies

Be the first to reply!

Reply