Set Due Date of a Task (Bonita Community 7.10.3)
Hi,
I'm trying to set the due date of a task in studio (for example to add 2 days of current day). I have the following script:
Date currentDate = new Date();
Calendar c = Calendar.getInstance();
c.setTime(currentDate);
c.add(Calendar.DATE, 2);
Date currentDatePlusTwo = c.getTime();
apiAccessor.processAPI.updateDueDateOfTask(activityInstanceId,currentDatePlusTwo);
But, it did't change the due date of the task. Can someone help me?
Thanks in advance,
Diana
Hello,
You should not call the API.
1/ Select the human task
2/ go to "general", then "portal"
3/ on the "due date calculation", click on the pencil
4/ select groovy, and put your code there. You should return currentDatePlusTwo.getTime()
You can't update this value by a connector. When you do that, after connectors execution, the portal will prepare the task and then execute all these scripts: the due date is reset.
You can use the API only on a task already visible.
Best,
Comments
Solved!
Hi Diana
Please share the working example so that we can also use the same.
Also did you put the Script as a connector on the human Task.
Regards
Hi,
Thank you so much for your answer. I use a different approach. Something like this:
import java.util.concurrent.TimeUnit;
int nDays = 10;
return TimeUnit.MILLISECONDS.convert(nDays, TimeUnit.DAYS);