Notifications during Task Life Cycle

In most common situations we might across the requirement to have different types of notifications during the life cycle of task.
Example : 1) Trigger Notifications on 30%,70% & 110% of task duration. to stating that task is waiting for accomplish the business needs.
Well that’s it. and we may think to use attached timers around task to get it down, fire on specific due dates on each timers… initially its look so rude to have three attached timers on a task. is in it?

lets begin to analyze it clearly.

"DUE IN" is priority setting for a user task, defines when task will be expected to complete.
based on this value and calculate the TWDate based on 30%, 70% & 110% duration of task.

Well one interesting scenario is to calculate TWDate excluding holidays, Yes count on only business days :).

We will talk about how to do it in another posts. lets assume we done calculation of three specific dates, Lets proceed with the implementation.

You may be interested in one of JS api – tw.system.rescheduleTimer(timerId, time)

Yep, you can reschedule timer by calling this api, passing parameters are timer id and TWDate.

Initialize the flag as shown in figure to capture or track the values of 30%, 70% and 110%. Most probably on Pre-Assignment’s of user task. lets say tw.local.flag = “30”;
pull one timer and attached on user task. and define the timer Id tw.local.timerId =; set the custom date on timer, obviously it was calculated 30% due date.
Set the flag script as shown below.
its bit tricky to have set the flag like this, the main intention is. initially we already set the date in a timer for 30%, as per the cycle notification send for 30%task duration again  its set to 70% custom date notification and vice versa by using js api as shown in code

}else if(tw.local.notifAFPFlag=="70"){
}else if(tw.local.notifAFPFlag=="110"){


JS function look like in below code.

function reScheduleForReminders(taskDueInHours,timerId,flag){
//var taskDueInHours = taskDueInHours;
if(flag == "30"){"###--------------->Welcome to 30% task duration<------------###"); var thirtyPercentInHours = Math.ceil(taskDueInHours/100 * 30);"thirtyPercentInHours---->"+thirtyPercentInHours);
var thirtyPercentDate = calcuateBusinessDate(tw.env.TIME_SCHEDULE_NAME,new TWDate(),thirtyPercentInHours,"Hour")"thirtyPercentDate---->"+thirtyPercentDate);
tw.system.rescheduleTimer(timerId, thirtyPercentDate);
}else if(flag == "70"){"###--------------->Welcome to 70% task duration<------------###"); var seventyPercentInHours = Math.ceil(taskDueInHours/100 * 70);"seventyPercentInHours---->"+seventyPercentInHours);
var seventyPercentDate = calcuateBusinessDate(tw.env.TIME_SCHEDULE_NAME,new TWDate(),seventyPercentInHours,"Hour")"seventyPercentDate---->"+seventyPercentDate);
tw.system.rescheduleTimer(timerId, seventyPercentDate);
}else if(flag == "110"){"###--------------->Welcome to 110% task duration<------------###"); var hundredTenPercentInHours = Math.ceil(taskDueInHours/100 * 110);"hundredTenPercentInHours---->"+hundredTenPercentInHours);
var hundredTenPercentDate = calcuateBusinessDate(tw.env.TIME_SCHEDULE_NAME,new TWDate(),hundredTenPercentInHours,"Hour")"hundredTenPercentDate---->"+hundredTenPercentDate);
tw.system.rescheduleTimer(timerId, hundredTenPercentDate);
} else{"###--------------->Welcome Infinite Loop<------------###"); var date=new tw.object.Date(); date.parse("12/31/2099","MM/dd/yyyy");"reschedule to infinite--date-->"+date);
tw.system.rescheduleTimer(timerId, date);

Leave a Reply

Your email address will not be published. Required fields are marked *