Defining task expiration

Hello,

I’m having two different problems when working with task expiration:

  1. Set task expiration based on a business field:
    I’ve created an event rule to set the task expiration some minutes after the task is queued. It works properly when hardcoding the value of the “Minutes after start date” but it does not work if I specify a business field to obtain the value from. I’ve already checked that the field contains the desired value and also have tried with different field formats (int, long and string); in all the cases, the expiration date is just not set to any value.

  2. Set task to “expired” from a button action inside the task implementation:
    Is there any option to do that without using the task engine webservices? I’m able to obtain a reference to the current task (getTaskInfo()), but I cannot see any way to modify its status. Even trying to set the expiration date to “now” (setExpireDate(new java.util.Date());) does not updates its status. I’m trying to do that inside the task implementation, so it seems that accessing the Task Engine webservices should not be needed.

Any suggestion about the two questions would be welcomed!

Finally, I found a solution to the 2 problems, thanks to the support team:

Problem 1: It seems it only appears on version 7.1.2. A method to implement such funcionality could be:

creating a change rule as:

Condition:
#{oldTask.taskInfo.status} == “new” && #{currentTask.taskInfo.status} == “active”

Action:
#{currentTask.taskInfo.expireDate} = #{currentTask.newExpirationDate} ; #{currentTask.applyChanges}

In your task client, you should code something like the following.
Code assumes that the IS Document (in this case PDoc) has a field called “days”.

public java.util.Date getNewExpirationDate()throws Exception {
java.util.Date created = getTaskInfo().getCreatedDate();
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.setTime(created);
cal.add(java.util.Calendar.DATE, getTaskData().getPdoc().getDays());
return cal.getTime();
}

Problem 2:
The method applyChanges() must be called after the task information is updated so the changes are persisted.