Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

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.
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 (11.27 KiB) Viewed 820 times
(34.73 KiB) Downloaded 46 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.

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
-f timereventcron.php
Processing workspace: workflow
| Not exists any record to start a new case, on date "2018-05-14 09:41:02 (UTC +
| > 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

Call to a member function initRBAC() on null

Finished 1 workspaces processed

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!
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'=>'[email protected]',
   'role'=>'PROCESSMAKER_ADMIN', 'password'=>'[email protected]'));
@@result = $client->__SoapCall('createUser', $params);
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 (57.14 KiB) Viewed 411 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....
What version of PM do you have?
You should see XML code when you paste that URL into your web browser:
webServicesXmlUrl.png (146.52 KiB) Viewed 401 times
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.
I have seen problems resolving $_SERVER['SERVER_ADDR'] on some installations.

Try hard coding in the URL:
Code: Select all
$client = new SoapClient('');
(changing the URL to match your system).

Post the code of your requests.Request work. You m[…]

Hi, seems like I am not allowed to log into proces[…]

Thanks for the reply :P

No, This answer was not working because I need the[…]