Discussion about developing the ProcessMaker application and suggestions for improving it
User avatar
By bobPuebla
#822221
Hi! I have a problem with scheduled tasks. The problem is that despite the tasks seem to be executed, the scripts don't perform any action

In this process there are 3 different scheduled cases running all the time. They run in a endless loop with an intermediate timer event and a script task which executes once a day, one of these scripts executes PMFNewCase, in order to create new cases according to predefined structure. The other two tasks send notifications using PMFSendMessage
image192.png
image192.png (29.85 KiB) Viewed 13938 times
each task seem to be executed correctly by intermediate timers, but scripts don't perform any action. If I run those scripts manually they perform perfectly
Selección_076.png
Selección_076.png (24.86 KiB) Viewed 13947 times
I 'd really appreciate your help
Attachments
Selección_075.png
Selección_075.png (43.54 KiB) Viewed 13947 times
User avatar
By amosbatto
#822233
Have you set up your ProcessMaker server to periodically execute the timereventcron.php file, as a cron job in Linux or a Scheduled Task in Windows? See: https://wiki.processmaker.com/3.2/Executing_cron.php
(If you are using LInux, make sure that you read the documentation about how to properly execute the file.)

If you can't get it to work, post how you set up your cron job or Scheduled Task.
User avatar
By bobPuebla
#822263
thanx for your answer amosbatto

Well, I believe that it was properly executed. The cron status indicates Active and there are events listed, look at the cron actions log:
image72.png
image72.png (106.7 KiB) Viewed 13926 times
User avatar
By amosbatto
#822264
If you execute the timereventcron.php file manually, do you see any errors when those script tasks are executed?
Have you executed the triggers in those script tasks as normal triggers inside a normal task to verify that they work? Run with the debugger enabled to see whether there were any errors.

Some system variables aren't updated correctly in script tasks. From the documentation:
Note: The system variables which are available during a script task are the variables that were set during the previous normal task in the process, so the value of the @@USR_USERNAME and @@USER_LOGGED variables will be set to the last user who worked on the case. Similarly, @%INDEX will be set to the delegation index of the previous normal task in the process. If the delegation index of the current script task is necessary, then it will be @%INDEX + 1 if the script task follows a normal task, or @%INDEX + 2 for the second script task after a normal task.
If none of those things is the problem and you can't figure it out, then you can always create three PHP files to execute the triggers using web services. Each of the files would have code like the following:
Code: Select all
<?php
ini_set("soap.wsdl_cache_enabled", "0");
ini_set('error_reporting', E_ALL);
ini_set('display_errors', True);

//If not executing this on your ProcessMaker server, then change the domain/IP address:
$client = new SoapClient('http://localhost/sysworkflow/en/neoclassic/services/wsdl2'); 
$username = 'admin'; //set to username
$pass = 'p@sSw0rD';  //set to password
$params = array(array('userid'=>$username, 'password'=>$pass));
$result = $client->__SoapCall('login', $params);

if ($result->status_code == 0)
   $sessionId = $result->message;
else
   print "Unable to connect to ProcessMaker.\nError Number: $result->status_code\n" .
         "Error Message: $result->message\n";

$params = array(array(
   'sessionId'=>$sessionId, 
   'caseId'=>'9782409664a7c94433d0920003544388',  //set to the ID of the case
   'triggerIndex'=>'3126831054a7dd8781e84a7046772575',  //set to ID of trigger
   'delIndex'=>'1' 
));
$result = $client->__SoapCall('executeTrigger', $params);

if ($result->status_code != 0)
   print "Error: $result->message \n";
?>
Then, your process to execute the trigger would be just a single task:
singleTaskProcess.png
singleTaskProcess.png (10.19 KiB) Viewed 13919 times
Then, start a case with the debugger enabled to see the Case ID in the APPLICATION system variable, so you can set it in the above code. Don't end the case, so it will be open forever and triggers can be executed in it forever.
User avatar
By amosbatto
#822483
You can create an empty dynaform and set the triggers to fire before the dynaform. You only need to create one case and never close it. All 3 scripts can use the same case in order to execute the triggers.
User avatar
By amosbatto
#822524
bobPuebla wrote: Tue Jan 22, 2019 11:15 am thanx for you answer, it seems so easy, but if we use a simple task, how can be sure that this will be executed everyday??
all 3 triggers must be executed once everyday
Oh, I forgot to mention that part. You need to create a Scheduled Task in Windows or a cronjob in LInux to execute your custom PHP files:
php script1.php
php script2.php
php script3.php

If you don't know how to schedule a cron job in Linux or a Scheduled Task in Windows, the basic idea explained here:
https://wiki.processmaker.com/3.2/Execu ... nux.2FUNIX
https://wiki.processmaker.com/3.2/Execu ... in_Windows
Just change the instructions to execute your custom PHP files.

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[…]