cancel
Showing results for 
Search instead for 
Did you mean: 

Time Duration support in User Task Due Date

balsarori
Champ on-the-rise
Champ on-the-rise
Hi,

Task due dates are commonly used as relative dates (relative to task creation date) and if I am not mistaken, the only way to set task relative due date is by using an external bean. I suggest to add support for ISO8601 Durations format in user tasks due date similar to time duration in Timer Event Definitions.

This will make it easier to set relative due dates in tasks without the need of using an external bean. For example, a user task with one month relative (relative to task creation date) due date can be set as follows:


<userTask id="theTask" name="Important task" activiti:dueDate="P1M"/>

I tried to implement this by editing resolveDuedate() method of org.activiti.engine.impl.calendar.DueDateBusinessCalendar as follows:

[java]
    try {
       
       // check if duration was specified
       if(duedate.startsWith("P")){
          return DateTime.now().plus(Period.parse(duedate)).toDate();
       }
          
      return DateTime.parse(duedate).toDate();

[/java]

It seems to work properly (although I can not say that I tested all cases).

Another way this can be supported is by using a special attribute in user task such as the following:


<userTask id="theTask" name="Important task" activiti:timeDuration="P1M"/>


I think that such support would be useful. What do you guys think? Will such support be useful and whats the best way to implement it?

5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
You can implement the solution in a Pull-request and create tests for it so all edge-cases and normal usage is covered. Once ready, submit the pull-request on github and we can take a look at it!

balsarori
Champ on-the-rise
Champ on-the-rise
Thanks for your reply.

Should it be implemented by using the due date attribute 'activiti:dueDate' or by adding a separate attribute 'activiti:timeDuration' ?

I think that if its going to work with no issues on the same 'activiti:dueDate' attribute, then no need to add a new attribute. What do you think?

frederikherema1
Star Contributor
Star Contributor
The timer-definition has a separate attribute/element for timeDuration. However, to keep it clear it's the "dueDate" we're targeting with the time-duration, "activiti:timeDuration" won't be a good fit imho. So it makes sense to reuse the existing property. It's easy to differentiate between an expression (${…}) and a period. So go ahead and reuse the dueDate attribute.

balsarori
Champ on-the-rise
Champ on-the-rise

frederikherema1
Star Contributor
Star Contributor
Thanks. For completeness, could you please sign the contribution agreement (http://activiti.org/Alfresco_Contribution_Agreement.pdf) so we have all paperwork sorted, that would be great Smiley Wink You can send it to tijs dot rademakers at alfresco dot com.