Setting Workflow Escalation in terms of Business Days

0 Likes
Hi,

I just came across a scenario and thought of sharing this solution with you all.

Usually, we set escalations while designing a workflow but never think of situation where escalation is for two days and request goes for approval on Friday. In such a scenario we often end up escalating the request by Monday which is incorrect.

I have written an ECMA Script code that can be used to evaluate escalation considering Business Days. You may include this in Mapping activity of a workflow and then use it in Approval activity to set escalation days.
function calculateBusinessDays(valEscalationDays)
{
var datetoday = new Date();
var evalYear = datetoday.getFullYear();
var evalMonth = datetoday.getMonth();
var evalDate = datetoday.getDate();
var evalHrs = datetoday.getHours();
var evalMins = datetoday.getMinutes();
var evalSecs = datetoday.getSeconds();
var evalMs = datetoday.getMilliseconds();

var initialEscalationDays = valEscalationDays;
var finalEscalationDays = valEscalationDays;
var counter = 1;
for(counter = 1; counter <= initialEscalationDays; counter )
{
var chkDate = evalDate counter;
var datetoday = new Date(evalYear, evalMonth, chkDate, evalHrs, evalMins,evalSecs, evalMs);
var dayofweek=datetoday.getDay();
if(dayofweek == 6.0)
{
finalEscalationDays ;
finalEscalationDays ;
}
}

return finalEscalationDays.toString();
}

Hope that helps!

Regards,
Simran Jeet Singh

Tags:

Labels:

How To-Best Practice
Comment List
  • I like this! Now how about a way to handle holidays? Maybe define a structure where you can identify the days of the year that are holidays? Then every country would have to define their own values for that structure?

    Managing dates suck!
Related
Recommended