Page 1 of 1

how to schedule trigger to run daily once

Posted: Thu May 10, 2018 7:13 am
by njhajhajha
Hello,
I am using process maker 3.2.2,i have written a single trigger in a process i want that trigger to be executed daily without any user action.

Please provide some solution.

Re: how to schedule trigger to run daily once

Posted: Thu May 10, 2018 4:20 pm
by amosbatto
You need to create a process that runs in a endless loop with an intermediate timer event and a script task which executes once a day, like this:
looparoundExecuteOncePerDay.png
looparoundExecuteOncePerDay.png (11.27 KiB) Viewed 6742 times
(34.73 KiB) Downloaded 288 times
Start a case in the process and let it run forever.

Setup a cron job in Linux or a Scheduled Task in Windows to periodically execute the timereventcron.php file on your server.

Re: how to schedule trigger to run daily once

Posted: Mon May 14, 2018 6:16 am
by njhajhajha
hey,

I have used
PMFCreateUser('name', 'nuc1234', 'surname', 'uname', 'mail', 'PROCESSMAKER_OPERATOR');
in my (Trigger to execute once per day)Script task .

When i run (timereventcron.php) it gives me this:and does not create user in PM.



Process maker 3.2.2, OS:Windows
-----------------------------------------------------------------------------------------------------------------------
C:\Bitnami\processmaker-3.2.2-0\apps\processmaker\htdocs\workflow\engine\bin>php
-f timereventcron.php
Processing workspace: workflow
+------------------------------------------------+
| Not exists any record to start a new case, on date "2018-05-14 09:41:02 (UTC +
00:00)"
+------------------------------------------------+
| > Continue the case #568
| > Routing the case #568...
PHP Fatal error: Call to a member function initRBAC() on null in C:\Bitnami\pro
cessmaker-3.2.2-0\apps\processmaker\htdocs\workflow\engine\classes\WsBase.php on
line 1030


[Symfony\Component\Debug\Exception\FatalErrorException]
Call to a member function initRBAC() on null


Finished 1 workspaces processed
Done!

-------------------------------------------------------------------------------------------------------------------
But when i run this trigger manually without intermediate timmer event i works fine and user get created in PM.

Please help in find the solution!
thank you!

Re: how to schedule trigger to run daily once

Posted: Mon May 14, 2018 11:29 am
by amosbatto
Here is what is happening. PMFCreateUser() is calling wsBase::createUser() which in turn calls RBAC::initRBAC(), which needs a valid user login. Since you are running a script task outside the user interface, there is no valid login.

The workaround is to web services in the trigger to login and then use the createUser() web service. That way you have a valid login when the script task is executed. Try using trigger code like this:
Code: Select all
$baseUrl = "http://{$_SERVER['SERVER_ADDR']}:{$_SERVER['SERVER_PORT']}/sys" . @@SYS_SYS .
$client = new SoapClient($baseUrl . '/en/neoclassic/services/wsdl2');
$user = 'johndoe';
$pass = 'pAsSw0rD';
$params = array(array('userid'=>$user, 'password'=>$pass));
$result = $client->__SoapCall('login', $params);

if ($result->status_code != 0) {
   throw new Exception("Unable to login to $baseUrl with user '$user' and password '$pass'.);
}
  
$sessionId = $result->message;
$params = array(array('sessionId'=>$sessionId, 'userId' => 'foobar',
   'firstname'=>'Foo', 'lastname'=>'Bar', 'email'=>'foobar@example.com',
   'role'=>'PROCESSMAKER_ADMIN', 'password'=>'fo0b@r'));
@@result = $client->__SoapCall('createUser', $params);

Re: how to schedule trigger to run daily once

Posted: Tue May 15, 2018 1:13 am
by njhajhajha
thank you!!
it works!!

Re: how to schedule trigger to run daily once

Posted: Mon Dec 03, 2018 3:40 pm
by richvle
Is this the correct path of the file?
"$client = new SoapClient($baseUrl . '/en/neoclassic/services/wsdl2');"
Because the error I receive is saying it's elsewhere.
Capture2.JPG
Capture2.JPG (57.14 KiB) Viewed 6333 times
I was able to locate the file here, "\apps\processmaker\htdocs\workflow\engine\methods\services" but not sure the proper format for the folders....

Re: how to schedule trigger to run daily once

Posted: Mon Dec 03, 2018 9:03 pm
by amosbatto
What version of PM do you have?
You should see XML code when you paste that URL into your web browser:
http://<ip-or-domain>/sys<workspace>/en/neoclassic/services/wsdl2
webServicesXmlUrl.png
webServicesXmlUrl.png (146.52 KiB) Viewed 6323 times

Re: how to schedule trigger to run daily once

Posted: Fri Dec 07, 2018 11:56 am
by richvle
I'm using version 3.1.1. And you are correct, I do see the XML file. However, when I tried to view the WDL2 on the application server that it's installed on, IE's security settings is blocking it. Perhaps that's where it's getting stuck.

Re: how to schedule trigger to run daily once

Posted: Fri Dec 07, 2018 6:49 pm
by amosbatto
I have seen problems resolving $_SERVER['SERVER_ADDR'] on some installations.

Try hard coding in the URL:
Code: Select all
$client = new SoapClient('http://example.com/sysworkflow/en/neoclassic/services/wsdl2');
(changing the URL to match your system).