My problem is that I have to put this query in the task itself, so it only updates after the user has opened the task at least once. How can I get it to update right when it is assigned? I tried to put it in the "after routing" bit of the previous task, but it didn't work, I guess because it gets the wrong @@TASK id. How can I get this done?

i have a paralel task and this code only set one of them due date as show as image. how can we set all paralel tast due date together?
i am using 2 trigger for that one of them is your another one is yours too but MAX(DEL_INDEX-1) like that

//set to the IDs of parallel tasks 1 and 2:
$parallelTask1Id = 'XXXXXXXXXXXXXXXXXXX';
$parallelTask2Id = 'XXXXXXXXXXXXXXXXXXX';
if (empty(@@dueDate)) {
throw new Exception("Didn't select the Due Date for next tasks");
}
$caseId = @@APPLICATION;
$dueDate [email protected]@dueDate;
//set the due dates in the two parallel tasks:
$query = "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$duedate'
WHERE APP_UID='$caseId' AND (TAS_UID='$parallelTask1Id' OR TAS_UID='$parallelTask2Id')
AND DEL_THREAD_STATUS='OPEN' ";
@@setDueDate = executeQuery($query);
$query2 = "UPDATE APP_CACHE_VIEW SET DEL_TASK_DUE_DATE='$duedate'
WHERE APP_UID='$caseId' AND (TAS_UID='$parallelTask1Id' OR TAS_UID='$parallelTask2Id')
AND DEL_THREAD_STATUS='OPEN' ";
@@setDueDate2 = executeQuery($query2);

You have to set the IDs of the two parallel tasks. You can find them by looking at the TASK system variable in the debugger while running a case or by searching in the TASK.TAS_UID field in the database.

if using PM 3.0.18 or later, you will also have change your configuration files to be able to write directly to the ProcessMaker tables in the database.
Edit the file workflow/engine/config/execute-query-blacklist.ini in the PM source code and change the following line from:

What if the next task is assigned to a user group, so it isn't actually assigned to any user yet? And the previous tasks were script tasks. Any updates we do prior will effect a previous script task delegation, not the current task delegation.

amosbatto wrote: ↑Mon Jun 11, 2012 9:02 pm
Use this code in a trigger fired after routing of the previous task:

richvle wrote: ↑Wed Dec 05, 2018 4:05 pm
What if the next task is assigned to a user group, so it isn't actually assigned to any user yet? And the previous tasks were script tasks. Any updates we do prior will effect a previous script task delegation, not the current task delegation.

There is no way to set the due date of the next task after a script task, because the database record for the next task does not yet exist in the APP_DELEGATION table when the trigger for a script task is fired.

What you need to do is delete your script task and set its trigger to fire after routing in a normal task.

The other option is to set the trigger to fire before the first step in the same task whose due date needs to be set. Most users look at the due date before opening a task, so this is only helpful for users who open the task, but don't immediately complete it. If you do this, then the trigger code would be different:

I tried the second route and it doesn't look like it's updating, or perhaps it's being overwritten. But I agree, I would like the users to be able to see the due date there before they claim the case (at IT Support Review).

As for the first solution, I was able to move some of the trigger into tasks, however, there are certain triggers prior to that that I couldn't because it only gets triggered after a gateway.

I added the trigger to "Before Dynaform" for the task as well. And it doesn't kick in. However, when the user claims the case, it moves the case to their inbox and if we look in the inbox, we can see the correct due date.