Escalations and Working Hours


Badge +5
I'm assuming that SetEscalationRule(Days, Hours, Minutes, Seconds,0) uses Working Hours, but SetEscalationRule(DateTime) does not. Correct?

We have a business rule that a support case can be placed on hold (in a Hold Activity) for a user-specified number of *business* days. After that time, the instance is to escalate at noon into a different Activity.

If 10 business days elapse from process start, though, the instance escalates out of hold regardless.

How would one code this? (Note the requirement to escalate at noon).

My first attempt was as follows, but this does not use business days/Working Hours. I have not found anything in the KO assembly that gives access to Working Hours calculations. Previous tests with multiple calls to SetEscalationRule have given unexpected results.

Thank you!

public void Main(EscalationRuleContext K2)
{
int requestedHoldDays = (int)K2.ProcessInstance.DataFields["holdDays"].Value;

DateTime currentDateTime = DateTime.Now;

DateTime finalCutoffDateTime = K2.ProcessInstance.StartDate.AddDays(10);

DateTime requestedHoldUntil = currentDateTime.Date.AddHours(12).AddDays(requestedHoldDays);

if (requestedHoldUntil < finalCutoffDateTime)
{
K2.SetEscalationRule(requestedHoldUntil);
}
else if (finalCutoffDateTime > currentDateTime)
{
K2.SetEscalationRule(finalCutoffDateTime);
}
else
{
// cutoff is in past - escalate immediately
K2.SetEscalationRule(currentDateTime.AddSeconds(1));
}
}

0 replies

Be the first to reply!

Reply