We use escalations in our workflow process. The intention was to calculate a due date based on the start date + the activity expected duration, then add 7 days before performing the escalation action (email). repeat every 7 days up to 10 times until the activity has been completed.
Each client activity has an escalation rule that calls an 'Escalate' function in a code module. This is the function:
Public Shared Sub Escalate (K2 As EscalationRuleContext)
Dim ExpectedDuration As Long 'expected duration of the calling activity - expressed in minutes
Dim StartDateTime As DateTime 'StartDateTime of the calling activity
Dim EscalationDateTime As DateTime 'will be start datetime plus expected duration plus 7 days
'Get start datetime of activity, add expected duration, then add 1 week. This is datetime of first escalation
StartDateTime = CType(K2.ActivityInstance.StartDate.ToString, Date)
ExpectedDuration = CType(k2.ActivityInstance.ExpectedDuration.ToString, Long)
EscalationDateTime = DateAdd(DateInterval.Minute, ExpectedDuration, StartDateTime)
EscalationDateTime = DateAdd(DateInterval.Day, 7, EscalationDateTime)
'first escalation is on EscalationDateTime; 10 more 7 days apart
K2.SetEscalationRule(EscalationDateTime, 7, 0, 0, 0, 10)
End Sub
And each activity has an escalation action - a simple email function.
So now we are having problems with escalation notices being sent out after an activity was completed, and even after the workflow was completed. The first one went like this:
- Step started on 12/28/07 7:27AM. 2 days expected duration, completed 1/7/08 8:39 am, a bit more than 25 hours after the first escalation time arrived.
- an escalation email was sent on this task on 1/13/08 7:27AM, more than 6 days after the activity was completed
And the second one like this:
- last step of workflow had 3 activity instances. They started on 12/27/07 2:03 pm, expected duration of 3 days, so the due date was 12/30/07 2:03 pm.
- the 3 instances were completed on 12/27/07 2:05 pm, 12/27/07 2:06 pm, and 1/7/08 3:48pm.
- All 3 folks received an email sent on 1/13/08 1:03 pm.
- the workflow completed on 1/7/08 3:48pm.
- This last activity executes a gotoActivity to a clean-up process - moving files to a completed folder, etc.
So what is going on? Why would the email get sent if the process was no longer active?