Set Due Date of a Task (Bonita Community 7.10.3)

1
0
-1

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

Comments

Submitted by diana.bento on Thu, 12/17/2020 - 12:55

Solved!

Submitted by Dibyajit.Roy on Thu, 12/17/2020 - 19:01

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

Submitted by diana.bento on Fri, 12/18/2020 - 10:26

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);

2 answers

1
+1
-1

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,

1
0
-1

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

Comments

Submitted by diana.bento on Fri, 05/14/2021 - 12:00

Hi, I use Bonita Community 7.10.3, maybe it was a bug in the versions that you use.

Diana

Submitted by jordicato on Fri, 05/14/2021 - 12:11

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

Notifications