Questions and discussion about using ProcessMaker: user interface, running cases & functionality
User avatar
By amosbatto
#793163
In my example, the case pauses in task1 when the email is sent out, so it is possible to route the case from Task1 to Task2 with the script in the decision.php file. If you want to send out the email with a trigger in the first task, but you want decision.php to route from the second task to the third task, then you need to set the userId and username fields in your email template to have information about the user assigned to the second task in your process.

Probably the best solution is to set the trigger which sends out the email to fire after routing in the first task. At that point, you can lookup the user which is assigned to the second task in the case in the APP_DELEGATION table, because the record already exists:
Code: Select all
$nextIndex = @%INDEX + 1; //index of task 2 in the case
$caseId = @@APPLICATION;
$sql = "SELECT USR_UID FROM APP_DELEGATION WHERE APP_UID='$caseId' AND DEL_INDEX=$nextIndex";
$result = executeQuery($sql);
@@task2UserId = $result[1]['USER_UID'];
$aUser = userInfo(@@userId); 
@@task2Username =  $aUser['username'];
$to = $aUser['mail'];
$aVars = array(
   'task2UserId' => @@task2UserId,
   'task2Username' => @@task2Username,
);
@@mailResult = PMFSendMessage(@@APPLICATION, 'admin@example.com', 
    $to, '', '', 'Approve Purchase Request #'.@@APP_NUMBER, 'approvalForm.html', $aVars);
Then change your template to this:
Code: Select all
<input type="hidden" name="caseId"   value="@#APPLICATION">
<input type="hidden" name="index"    value="@#INDEX">
<input type="hidden" name="userId"   value="@#task2UserId">
<input type="hidden" name="username" value="@#task2Username">


= $_GET['username']; In your process, is different, you need to send out the email in the second task or you allow the case to route to Task2,
By avi123
#793285
amosbatto wrote:In my example, the case pauses in task1 when the email is sent out, so it is possible to route the case from Task1 to Task2 with the script in the decision.php file. If you want to send out the email with a trigger in the first task, but you want decision.php to route from the second task to the third task, then you need to set the userId and username fields in your email template to have information about the user assigned to the second task in your process.
Thank you @amosbatto. It is working fine.
But in my process, to skip below stage:
20.png
20.png (5.97 KiB) Viewed 10298 times
I used this code:
Code: Select all
PMFDerivateCase(@@APPLICATION, @%INDEX);
G::header("Location: casesListExtJsRedirector");
die();
And fired trigger before assignment. When I used this trigger it didn't work. Is there any way to use this trigger and approve/reject by email.
If I didn't use this trigger it works. If I want to fire triggers which are after dynaform then how should I do? Using executeTrigger?
Thanks & Regards
User avatar
By amosbatto
#793301
PMFDerivateCase() has an option to fire the triggers before assignment. You could move your trigger to before assignment. If you need to fire a trigger after a DynaForm, you have to manually execute it with the execute-trigger REST endpoint or the executeTrigger() web service. There is an internal function you can use to execute triggers:
wsBase::executeTrigger ($userId, $caseId, $triggerIndex, $delIndex)
Where $triggerIndex is the unique ID of the trigger.

For example,
Code: Select all
$ws = new wsBase();
$ws->executeTrigger(@@USER_LOGGED, @@APPLICATION, "1233456789abcde0123456789abcde", @%INDEX);
By avi123
#793373
amosbatto wrote:PMFDerivateCase() has an option to fire the triggers before assignment. You could move your trigger to before assignment. If you need to fire a trigger after a DynaForm, you have to manually execute it with the execute-trigger REST endpoint or the executeTrigger() web service. There is an internal function you can use to execute triggers:
wsBase::executeTrigger ($userId, $caseId, $triggerIndex, $delIndex)
Where $triggerIndex is the unique ID of the trigger.

For example,
Code: Select all
$ws = new wsBase();
$ws->executeTrigger(@@USER_LOGGED, @@APPLICATION, "1233456789abcde0123456789abcde", @%INDEX);
Where Should I place this trigger? It's not working.
In First task, user selects approvers. Then I saved approver's username and name. When approver approved/ rejected that case then I fired trigger which update approver's decision, comment and time. Same for second approver.
Code: Select all
$params = array(array('sessionId'=>$sessionId, 'caseId'=>'$caseId',
   'triggerIndex'=>'3126831054a7dd8781e84a7046772575','delIndex'=>'1'));
$result = $client->__SoapCall('executeTrigger', $params);
if ($result->status_code != 0)
   print "Error: $result->message \n";
This code doesn't fire trigger which I placed after dynaform.

Thanks & Regards
User avatar
By amosbatto
#793393
avi123 wrote: Where Should I place this trigger? It's not working.
It doesn't matter where the trigger is set to execute in your process. In fact the trigger should fire, even if it is not set to execute anywhere in the process.

If the trigger doesn't execute, then you either have an error in your code or are using an undefined variable in the trigger or the case where you are executing the trigger is assigned to a different user than the one who logged in to web services. For example, the case is assigned to Bob and you logged into web services with Alice.
By avi123
#793529
amosbatto wrote:
avi123 wrote: Where Should I place this trigger? It's not working.
It doesn't matter where the trigger is set to execute in your process. In fact the trigger should fire, even if it is not set to execute anywhere in the process.

If the trigger doesn't execute, then you either have an error in your code or are using an undefined variable in the trigger or the case where you are executing the trigger is assigned to a different user than the one who logged in to web services. For example, the case is assigned to Bob and you logged into web services with Alice.
Yeah, there is a following error.
Invalid argument supplied for foreach()
I got same error in my process as well. Even though my process works fine. When I call executeTrigger I got this error and that trigger didn't executed. See below topic.
viewtopic.php?t=709362
User avatar
By amosbatto
#793572
This code is bad:
Code: Select all
$params = array(array('sessionId'=>$sessionId, 'caseId'=>'$caseId',
   'triggerIndex'=>'3126831054a7dd8781e84a7046772575','delIndex'=>'1'));
$result = $client->__SoapCall('executeTrigger', $params);
if ($result->status_code != 0)
   print "Error: $result->message \n";
You can't insert a variable inside single quotes. It should be:
Code: Select all
$params = array(array('sessionId'=>$sessionId, 'caseId'=>$caseId,
   'triggerIndex'=>'3126831054a7dd8781e84a7046772575','delIndex'=>'1'));
$result = $client->__SoapCall('executeTrigger', $params);
if ($result->status_code != 0)
   print "Error: $result->message \n";
By avi123
#793581
amosbatto wrote: You can't insert a variable inside single quotes. It should be:
Code: Select all
$params = array(array('sessionId'=>$sessionId, 'caseId'=>$caseId,
   'triggerIndex'=>'3126831054a7dd8781e84a7046772575','delIndex'=>'1'));
$result = $client->__SoapCall('executeTrigger', $params);
if ($result->status_code != 0)
   print "Error: $result->message \n";
Thanks for reply. Here is my code for executeTrigger call.
Code: Select all
$params = array(array('sessionId'=>$sessionId, 'caseId'=>$_GET['caseId'],
       'triggerIndex'=>'67468261759489ccd1582e9094403496','delIndex'=>$_GET['index']));
	   var_dump($_GET['index']);
 $result = $client->__SoapCall('executeTrigger', $params);
 if ($result->status_code != 0){
	  die("<html><body><pre>Error: $result->message </pre></body></html>");
 }
I don't think anything wrong in it.
and I gave you a link of topic that person is also faced same problem.
My process is worked fine when users use processmaker tool, when users use email to approve/ reject case then trigger is not called and it shows error messages Invalid argument supplied for foreach(). I got same error message in processmaker but that doesn't effect on any trigger.

Thanks & Regards
User avatar
By amosbatto
#793598
I wonder if the problem is that the delegation index number for the case has changed. It will be incremented every time the case routes to another task or the case is assigned to another user. Another possible problem is that another user is now assigned to the case rather than the one who is logged in with web services.
By avi123
#793645
amosbatto wrote:I wonder if the problem is that the delegation index number for the case has changed. It will be incremented every time the case routes to another task or the case is assigned to another user. Another possible problem is that another user is now assigned to the case rather than the one who is logged in with web services.
No, it is not a problem. Is there any way to fire trigger?
User avatar
By amosbatto
#793653
I just tried using the executeTrigger web service in PM 3.2 Community and I have no problems. Can you post the code of your trigger that you are trying to execute? Maybe you are trying to access a system variable which isn't defined.

Also, if you go into the APP_DELEGATION table in the database, can you verify that a record exists for the case ID (APP_UID) and the index number (DEL_INDEX) which you are using with the executeTrigger web service()? The DEL_TREAD_STATUS should be 'OPEN' and the USR_UID should be the same user who is logged into web servers.
By atuly7
#795265
amosbatto wrote:I just tried using the executeTrigger web service in PM 3.2 Community and I have no problems. Can you post the code of your trigger that you are trying to execute? Maybe you are trying to access a system variable which isn't defined.

Also, if you go into the APP_DELEGATION table in the database, can you verify that a record exists for the case ID (APP_UID) and the index number (DEL_INDEX) which you are using with the executeTrigger web service()? The DEL_TREAD_STATUS should be 'OPEN' and the USR_UID should be the same user who is logged into web servers.
Hi @amosbatto, I just tried this code and works perfectly.
When user click on submit button it redirected to .php page and it opened in browser like this.
111.png
111.png (67.45 KiB) Viewed 9958 times
I want to hide this page from user or don't want to show to user. And onclick of submit button just show some message like Request is submitted.
Is there any way to do this?

Thanks & Regards
User avatar
By amosbatto
#795276
atuly7 wrote: When user click on submit button it redirected to .php page and it opened in browser like this.
111.png
I want to hide this page from user or don't want to show to user. And onclick of submit button just show some message like Request is submitted.
Is there any way to do this?
Comment out the var_dump() statement like this:
//var_dump(...);
Then look for the text "Form submitted and case routed" and change it in the code. If you can't figure it out, then post your code.
By atuly7
#795287
amosbatto wrote: Comment out the var_dump() statement like this:
//var_dump(...);
Then look for the text "Form submitted and case routed" and change it in the code. If you can't figure it out, then post your code.
I think you didn't get my question.
If I comment var_damp(.. );
Then it only hides that above message .
But when user clicked on submit button then it redirected to decision4.php page . Can I run that page in background ? I don't want to show that page to user.
If it is not possible then redirected page which shows
After routing
Trigger's Name which is fired after routing .
I want to hide that trigger's Name.
By atuly7
#795452
amosbatto wrote:Then use header("location: $url"); to redirect the web browser instead of displaying that page.
Code: Select all
<?php
require_once "dbCredentials.php";
ini_set("soap.wsdl_cache_enabled", "0");
//ini_set('error_reporting', E_ALL); //uncomment to debug
//ini_set('display_errors', True);  //uncomment to debug
if (!isset($_GET['decision'])) {
  die("The GET variable Decision is not set!");
}

$userId   = $_GET['userId'];
$username = $_GET['username'];
//lookup the password hash for the user assigned to the "Request Items" task in the database
$conn = mysql_connect($dbDomain, $dbUser, $dbPassword) or
   die("Error connecting to MySQL database.\n");
$ret = mysql_select_db($dbWorkspace);
$result = mysql_query("SELECT USR_PASSWORD FROM RBAC_USERS WHERE USR_UID='$userId'") or
   die("Error: Unable to query the USER table.\n");
$record = mysql_fetch_array($result, MYSQL_ASSOC);


if (!$record) {
   die("Error: Unable to find password for '$username' in the USER table.\n");
}

$client = new SoapClient('http://192.168.11.55:81/sysworkflow/en/neoclassic/services/wsdl2');
$pass = 'md5:' . $record['USR_PASSWORD'];
$params = array(array('userid'=>$username, 'password'=>$pass));
$result = $client->__SoapCall('login', $params);

if ($result->status_code == 0) {
   $sessionId = $result->message;
} 
else {
   die("<html><body><p></p>Unable to connect to ProcessMaker.<br>\n" .
      "Error Message: <pre>$result->message</pre></p></body></html>");
} 

class variableStruct {
    public $name;
    public $value;
}
 
$decision        = new variableStruct();
$decision->name  = 'decision';
$decision->value = $_GET['decision'];

$comments        = new variableStruct();
$comments->name  = 'comment';
$comments->value = $_GET['comment'];
 
$variables = array($decision, $comments);
$params = array(array('sessionId'=>$sessionId, 'caseId'=>$_GET['caseId'], 'variables'=>$variables));
$result = $client->__SoapCall('sendVariables', $params);

if ($result->status_code != 0) {
   die("<html><body><pre>Error: $result->message </pre></body></html>");
}


$params = array(array('sessionId'=>$sessionId, 'caseId'=>$_GET['caseId'],
       'triggerIndex'=>'7167053225966f7944ccc81013859952','delIndex'=>$_GET['index']));
 $result = $client->__SoapCall('executeTrigger', $params);
 if ($result->status_code != 0){
      print "Error: $result->message \n";
	  //die("<html><body><pre>Error: $result->message </pre></body></html>");
 }
 
$params = array(array('sessionId'=>$sessionId, 'caseId'=>$_GET['caseId'], 'delIndex'=>$_GET['index']));
$result = $client->__SoapCall('routeCase', $params);
if ($result->status_code != 0) {
   die("<html><body><pre>Error: $result->message </pre></body></html>");
}


print "<html><body><p>Form submitted and case routed:<br>\n".$result->message."</p></body</html>";

?>
How will I convert this php code into java?
I have a doubt. decision is an variable for approve or reject the case. I am using wsdl by java. If decision is not set then can I route the case using routecase function of wsdl? or is it necessary to set that decision variable?

Thanks & Regards
User avatar
By amosbatto
#795458
atuly7 wrote:How will I convert this php code into java?
WSDL in Java looks harder than WSDL in PHP in my opinion, but I'm not a Java programmer, so I can't help you.
I have a doubt. decision is an variable for approve or reject the case. I am using wsdl by java. If decision is not set then can I route the case using routecase function of wsdl? or is it necessary to set that decision variable?
The variable @@decision is used in the conditions in an exclusive gateway in my example, so it is needed during routing. You can design your process to not use an exclusive gateway with conditions, so it isn't necessary to use the sendVariable() web service to send the @@decision variable to the case.
By KalKaush
#823423
Hi, I've gone through this forum and I'm having difficulty with recreating this example.

https://wiki.processmaker.com/index.php ... _via_Email

my flow looks identical to that of the tutorial (except that the 'Request Items' block is a script task). I have one dynaform for the user to enter their preferences and my php file looks like this:
Code: Select all
<?php
ini_set("soap.wsdl_cache_enabled", "0");
//ini_set('error_reporting', E_ALL); //uncomment to debug
//ini_set('display_errors', True);  //uncomment to debug
if (!isset($_GET['approved'])) {
  die("The GET variable approved is not set!");
}

$client = new SoapClient('http://192.168.11.55:81/sysworkflow/en/neoclassic/services/wsdl2');
$pass = 'md5:' . $record['USR_PASSWORD'];
$params = array(array('userid'=>$username, 'password'=>$pass));
$result = $client->__SoapCall('login', $params);

if ($result->status_code == 0) {
   $sessionId = $result->message;
} 
else {
   die("<html><body><p></p>Unable to connect to ProcessMaker.<br>\n" .
      "Error Message: <pre>$result->message</pre></p></body></html>");
} 

class variableStruct {
    public $name;
    public $value;
}
 
$decision        = new variableStruct();
$decision->name  = 'approved';
$decision->value = $_GET['approved'];

$variables = array($comments);
$params = array(array('sessionId'=>$sessionId, 'case'=>$_GET['case'], 'variables'=>$variables));
$result = $client->__SoapCall('sendVariables', $params);

if ($result->status_code != 0) {
   die("<html><body><pre>Error: $result->message </pre></body></html>");
}

$params = array(array('sessionId'=>$sessionId, 'case'=>$_GET['case'], 'delIndex'=>$_GET['index']));
$result = $client->__SoapCall('routeCase', $params);
if ($result->status_code != 0) {
   die("<html><body><pre>Error: $result->message </pre></body></html>");
}

print "<html><body><p>Form submitted and case routed:<br>\n".$result->message."</p></body</html>";

?>
I did not trigger within the code as I have triggered one of the blocks in my flow as a script task.

When I run this, the webpage shows:
"Undefined index: index in processmaker/htdocs/workflow/public_html/decision.php"
"Error: Case has been reassigned to another user" while the process map information shows that the process is still stuck in the "Intermediate Catch Timer" event. I checked the env.ini and php.ini files to ensure that the date.timezone is correctly set.

Why isn't the case being routed past the timer stage and entering the decision block?

Thanks,

Kal
User avatar
By amosbatto
#823441
Kal, It is hard for me to understand what is your problem without seeing your process. Can you either export your process and post the .pmx file or post a screenshot of the process in the designer?

What version of ProcessMaker are you using?

If you use this code:
Code: Select all
$pass = 'md5:' . $record['USR_PASSWORD'];
Then, $record['USR_PASSWORD'] needs to be set to the SHA64 hash of the user's password (or to the MD5 hash if using an older version of MySQL).

If you want to use an unencrypted password, then you need to use:
Code: Select all
$pass = $record['USR_PASSWORD'];
Check the web services documention for the login function for more info.

In the rapidly evolving world of online sports be[…]

STEPN integrates social networking and games that […]

Cenforce 150 is a medication used to cope with a c[…]

What's SAP FICO?

Trustworthy and skill-building, each of these actu[…]