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,
Diana,
Please, when you wrote SOLVED, what does you mean ?
I've the same problem. On before versions (v7.3.2) your Script was running ok, but in a newer versions not.
Thanks
Jordi
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);
Hi, I use Bonita Community 7.10.3, maybe it was a bug in the versions that you use.
Diana
Diana,
I was finally able to fix it. I am working with version 7.11.4
As Pierre-yves commented, I put the code inside Portal / Due Date calculation Script, but I had to calculate the difference between the current date and the due date, in milliseconds, and it worked correctly.
Thanks