Working with deadlines is the core of every tracking and time related process. Deadlines are really important for a project to be completed on time and additional resources are required if a project is lacking time. Good planning always involve using deadlines. In BPM also, Deadlines are given a lot of importance, if the deadlines are not met reminders can be generated for approval, moving forward, skipping activities and generating emails to the required participants a.k.a users.
There is a small problem that most of the industry and offices work in shifts and usually have one or two days off in a week, its an irony :), so calendar rules needed to be generated so that deadlines exist and expire in working time or when most of the staff are present on their desk. In addition to calendar rules we have also got both expected and unexpected holidays for example weekends, country national days, regional holidays like Religious festivals. The need is to include these holidays into our plan so that these holidays are not hurting the deadlines.
In the discussion below I will show how to use deadlines in a simple way with the integration of holiday and calendar rules. We start by using the simplest flow of inventory approval used in earlier post.
 |
Simple WorkFlow |
Now we want to add a deadline for the approval activity so that a reminder is generated after the deadline is passed. For example an email can be sent or if no activity is done in the deadline period it is reassigned to another participant.
 |
Deadline Added on Approval activity |
Check the swim line of Head of Department role, you can see a new automatic activity has been added with a due transition. In the due connector add the time of deadline.
 |
Inside Due transition |
This is the simplest way to add deadline. The variable entry is of interval type. Now see the workspace below showing 1 day deadline. Suppose we started the instance reached Approval Activity on Nov 17, 2011 and deadline is calculated after a day that is Nov 18, 2011.
 |
Workspace showing deadline |
Now we are going to add calendar and holiday rules and integrate them with deadlines.
Add Holiday Rule:
- Go to Organization, inside your project
- Right click Holiday Rules
- New
- Name it
- Then a new tab opens
- Click Add
- Add the Holiday you want for example suppose tomorrow Nov 18, 2011 is a holiday.
Add Calendar Rule:
- Go to Organization, inside your project
- Right click Calendar Rules
- New
- Name it
- Then a new tab opens
- Add your companies shift timings or necessary information, I have given Saturday and Sunday as Holiday. See Figure Below
- Add Holiday Rule made earlier into the Calendar Rule and Save it.
 |
Add Calendar Rules |
Now go to project Navigator -> Select Your project -> Your Module -> Right Click Module -> New -> BPM Object -> In the Object Make a method called set Calendar Deadlines and a variable integer for number of days.As shown in the figure below:
 |
Calendar Rule Code |
This is code inside the method for calendar deadlines. Make sure the server side method is Yes and return type is Interval, As seen in the figure above save it
//Code for Calendar Rule
calendar as CalendarRule
calendar = CalendarRule.fetch(calendarName : "CRule")
start as Time
memday as Time
start = 'now'
memday = start
newdead as Time
count as Int
count = 0
numDays=1
numDays=numDays+1
if numDays> 0 then
while count < numDays do
if (isHoliday(calendar, time : start) == false &&
isWorkDate(calendar, time : start) == true) then
count = count + 1
end
start = start + '1d'
end
start = start - '1d'
end
newdead=start
deadint as Interval
deadint=newdead-'now'
return deadint
Save Project. Go back to Due Activity -> Properties and write the code below Inside Due Transition.
PDProcess.CalRulOBject.setCalDeadlines(numDays:1)
<module>.<CalendarRuleObject>.<method>(variable:value)
Now if we calculate the new deadline like Nov 18, 2011 is holiday and Nov 19 and Nov 20 are weekly offs. The new deadline will be calculated to Nov 21, 2011. As show below.
 |
Deadline Solution |
Looking forward to any queries, suggestions and questions. Leave a comment here or E-mail me with reference to this topic.
Best Regards