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.
#814406
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 6730 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.
#814433
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!
#814436
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);
#821898
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 6321 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....
#821900
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 6311 times
#821951
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.
#821954
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).
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[…]