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.
#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 229 times
(34.73 KiB) Downloaded 17 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'=>'[email protected]',
   'role'=>'PROCESSMAKER_ADMIN', 'password'=>'[email protected]'));
@@result = $client->__SoapCall('createUser', $params);

Hello guys, I'm new in ProcessMaker and I have som[…]

DBA changed the php.ini file and the timezone is n[…]

Test SQL Query

I'm working on a suggested field, but I don't rece[…]