Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By Palele
#813009
Hello
I have a little problem. I have self service task and if someone accepts and doesnt't complete. That person have this in inbox. I would like to move task to folder unassigned after 1 hour. Is it possible?
I know that I could reassigned or change user by click but it must be auto after a time...
User avatar
By amosbatto
#813023
You will need to use two processes. First, create your process with a Self Service task which has an exclusive gateway to loop back to the Self Service:
LoopBackToSelfServiceTask.png
LoopBackToSelfServiceTask.png (18.29 KiB) Viewed 5009 times
The gateway will have these two conditions to either loop back to the Self Service task or route on to Task 3:
RoutingRulesLoopback.png
RoutingRulesLoopback.png (50.26 KiB) Viewed 5009 times

Then, create a second process with an intermediate timer that will periodically execute a script to check if there are any cases in the other process with the Self Service task which are 1 hour or older:
TimerProcessToExecuteScriptPeriodically.png
TimerProcessToExecuteScriptPeriodically.png (15.44 KiB) Viewed 5009 times
Then, add a trigger that routes on all the cases with the Self Service task which haven't been completed after an hour:
Code: Select all
//set to the ID of the Self Service task in the "Return To Unassigned" process
//or use PMFGetUidFromText() to get the task ID:
$taskId = '7825264095a726f6e45b0e3018763046';

$anHourAgo = date('Y-m-d H:i:s', strtotime('-1 hour'));

$sql = "SELECT * FROM APP_DELEGATION 
    WHERE TAS_UID='$taskId' AND DEL_THREAD_STATUS='OPEN' AND 
    DEL_INIT_DATE IS NOT NULL AND DEL_INIT_DATE < '$anHourAgo'";  
$aDelegations = executeQuery($sql);

if (!isset(@=aRoutedCases)) {
    @=aRoutedCases = array();
}

$g = new G();
$g->sessionVarSave();

foreach($aDelegations as $aDel) {
    $aVars = array(
        'returnToUnassigned' => true
    );
    PMFSendVariables($aDel['APP_UID'], $aVars);  
    PMFDerivateCase($aDel['APP_UID'], $aDel['DEL_INDEX'], false, $aDel['USR_UID']);
    
    $now = date('Y-m-d H:i:s');
    @=aRoutedCases[$now] = $aDel;
    $aVars['returnToUnassigned'] = false;
    PMFSendVariables($aDel['APP_UID'], $aVars); 
}

$g->sessionVarRestore();
I haven't had a chance to test this code, since I'm still waiting for a case to complete an hour, so you will have to test it. You will have to change the UID of $taskId to your Self Service task. You will also need to configure your PM server to periodically execute the timereventcron.php file, but first manually execute it to verify that the trigger code works correctly.

Here are the two processes to test this:
(35.61 KiB) Downloaded 408 times
(44.71 KiB) Downloaded 409 times
By Palele
#813051
Thanks. It's work but I have another problem with Cron. Manually It's works but if add a line into a crontab
* */1 * * * root /opt/bitnami/php/bin/php /opt/bitnami/apps/processmaker/htdocs/workflow/engine/bin/timeventcron.php

It doesnt't work. I try with sh script but ineffective.

edit:
I don't know what happend but after some time it's works. Thanks a lot :)
User avatar
By amosbatto
#813063
timereventcron.php has to execute twice before it starts working and it usually doesn't start working on my server until a day later on my server. I suspect a difference between time zone settings, but I haven't figured out why.
User avatar
By jemiris
#823879
I too have the same issues with timer event is not working. I tried manually it works the windows as well as Linux. Even though I tried with Linux below code. Not executing in Linux server dynamically.
Code: Select all
 15 * * * * apache php -f /opt/processmaker/workflow/engine/bin/timereventcron.php
Last edited by jemiris on Wed Nov 27, 2019 12:55 am, edited 1 time in total.
User avatar
By amosbatto
#823911
Do you have anything in your cron log file at /opt/processmaker/shared/log/cron.log ?
What version of PM?

Try adding the +force option:
15 * * * * apache php /opt/processmaker/workflow/engine/bin/timereventcron.php +force
User avatar
By jemiris
#823928
Thanks for the reply.Hi, guys if anyone gets timer event not working. Just give a +force command it works for me. I hope it will help someone.
Code: Select all
 15 * * * * apace-user-name php -f /opt/processmaker/workflow/engine/bin/timereventcron.php +force
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]