Set Due date programmatically in 6.3.x

1
0
-1

Hi! My client has a Due date specification where depending on several factors, a due date is defined. I use a connector to get this due date, but I don't know how to apply it to the Human task next to it.

Sure, I could use a Timer but I want to be able to see this Due date, or time left on the Portal. Is there a way to achieve this?

1 answer

1
0
-1

I use something like this...but it's not on the next task within a process, but a new process. At least it should point you in the right direction.

By assigning the dueDate to the process it will show on the portal in the tasks List (i.e due in 2 days etc.)

//all tasks get duedate = now() + 3 days
Calendar c = Calendar.getInstance();
int weekday = c.get(c.DAY_OF_WEEK);
if (weekday == c.MONDAY){c.add(c.DAY_OF_MONTH,3)}
if (weekday == c.TUESDAY){c.add(c.DAY_OF_MONTH,5)}
if (weekday == c.WEDNESDAY){c.add(c.DAY_OF_MONTH,5)}
if (weekday == c.THURSDAY){c.add(c.DAY_OF_MONTH,5)}
if (weekday == c.FRIDAY){c.add(c.DAY_OF_MONTH,5)}
if (weekday == c.SATURDAY){c.add(c.DAY_OF_MONTH,4)}
if (weekday == c.SUNDAY){c.add(c.DAY_OF_MONTH,3)}
c.setTime(new Date()); // Now use today date.
c.add(Calendar.DATE, 3); // Adding 3 days

//this is the new date
Date dueDate = c.getTime();


//Find the human activity
                SearchOptionsBuilder searchOptionsBuilder = new SearchOptionsBuilder(0, 100);
                searchOptionsBuilder.filter(HumanTaskInstanceSearchDescriptor.NAME, processIdent[0]);
                SearchOptions searchOptions = searchOptionsBuilder.done();
               
SearchResult<HumanTaskInstance> searchHumanTaskInstances = processAPI.searchHumanTaskInstances(searchOptions);

                for (HumanTaskInstance pendingTask : searchHumanTaskInstances.getResult()) {
                       
                        if (pendingTask.getParentProcessInstanceId().toString().equals(processProcessId[1].toString())){
                       
                                if (pendingTask.getId()>activityId){
//got it save the activity ID
                                        activityId = pendingTask.getId();
                                }
                        }
                }
               
                //Force the date on the process Human Task...
                try{
                                processAPI.updateDueDateOfTask(activityId, dueDate);
                        }
                        catch(Exception u1){
                        }

Hope it helps, regards Seán

Notifications