Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By Sicilio
#786486
Hi everyone,

I’m currently creating a process. In that process users should have the option to manually select a deadline for the following task.
I tried to realize this by using a trigger setting the duration for the next task based on the chosen deadline. But somehow I fail to update the task duration in the task table.
The SQL statement in general seems to work. When I change the “tas_transfer_fly” from false to true or vice versa its changed in the process. But the TAS_DURATION value does not change at all. Doesn’t matter if I insert a variable ($days) or a fixed number.

Any ideas how to fix this? Thanks in advance for your help.

Best regards
Sicilio


Code:

$PROCESS=@=PROCESS;
$datetime1 =strtotime(@=currentDate); // created by getCurrentDate function
$datetime2 =strtotime(@=Deadline); // Date variable chosen by user in Dynaform
$datediff = $datetime2 - $datetime1;
$days= floor($datediff/(60*60*24));
$result = executeQuery("UPDATE TASK SET TAS_DURATION='$days',TAS_TYPE_DAY='2',TAS_TRANSFER_FLY='FALSE' WHERE PRO_UID='$PROCESS' AND TAS_UID='27496337857c462cab192d9030379160'"); // TAS_UID from the task i want to set the duration for

SQL Statement taken from viewtopic.php?t=43299
User avatar
By amosbatto
#786489
Changing the TAS_DURATION in the TASK table is only recommended if you have one concurrent case and you have to set it before the case routes to the task. You are changing the definition of the task, so it is changed for all cases which have that task. This is a problem if user1 wants 2 days and user2 wants 4 days and they both are routing their case to the same task at the same time.

Instead, I recommend setting the DEL_TASK_DUE_DATE in the APP_DELEGATION and APP_CACHE_VIEW tables, but you can only do this after routing in the prior task or while the case is in the task, because the record for the case's task does not yet exist in the database.

Here is some sample trigger code you can use:
Code: Select all
$deadline = @@Deadline;  //from a date field in a DynaForm 
//assuming that setting for the current task in the current case:
$caseId = @@APPLICATION;
$index  = @=INDEX; //if setting for the next task in the process, then add 1 to the index

$sql = "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$deadline' WHERE APP_UID='$caseId' AND DEL_INDEX=$index";
@@result1 = executeQuery($sql);
$sql = "UPDATE APP_CACHE_VIEW SET DEL_TASK_DUE_DATE='$deadline' WHERE APP_UID='$caseId' AND DEL_INDEX=$index";
@@result2 = executeQuery($sql);
By tamasig
#788138
amosbatto wrote:you can only do this after routing in the prior task or while the case is in the task, because the record for the case's task does not yet exist in the database
It may be completely unfeasible, but is there any way to work around this if the prior case is a script task? (In other words, is there an equivalent to the option "After routing" for script tasks?)

Many thanks,
Gergely
User avatar
By amosbatto
#788264
This will not work for script tasks. However, there is no reason to have a script task if you can execute the same trigger in the previous task after routing.
User avatar
By amosbatto
#789469
Marcos, the structure of these tables has not changed in PM 3.1.3 compared to PM 2.X.

If you are setting the due date for the next task in the process, you need to do this and make sure to set your trigger to fire after routing in the prior task.
Code: Select all
$index  = @%INDEX + 1; 

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]