Article

sjeet's picture
article
Reads:

2508

Score:
5
5
2
 
Comments:

1

Setting Workflow Escalation in terms of Business Days

Author Info

31 August 2011 - 3:11pm
Submitted by: sjeet

(View Disclaimer)

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


Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).

It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.




User Comments

geoffc's picture

Business days

Submitted by geoffc on 31 August 2011 - 7:00pm.

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!

© 2013 Novell