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.
By higgledy
#813817
I am creating a case via the REST API. But now, I need to change the case status from DRAFT to TO DO, and am using a the REST Execute Trigger to do this. http://wiki.processmaker.com/3.0/Trigge ... s_to_TO_DO

My question is, how do I get the app_uid value inside the trigger? In the rest call I am sending the app_uid and tas_uid, but once my code is in the trigger how can I get the value of the app_uid that is in the call? Thanks.
By higgledy
#813824
thanks. So this should work?
Code: Select all
$newCaseId = @@APPLICATION;
if ($newCaseId) {
   $c = new Cases();
   $aCase = $c->loadCase($newCaseId);
   $aCase['APP_STATUS'] = 'TO_DO';
   $c->updateCase($newCaseId, $aCase);
};
Is there anyway to add logging statements to debug if the value expected is being assigned to $newCaseId?
User avatar
By amosbatto
#813826
You can set a case variable and then call GET /cases/{app_uid}/variables to verify that the variable is correct. If you have this trigger code:
@@newCaseId = $newCaseId;
After calling PUT /cases/{app_uid}/execute-trigger/{tri_uid}, then call GET /cases/{app_uid}/variables to verify the value of the "newCaseId" variable.
You can also do this:
Code: Select all
if (empty($newCaseId)) {
  throw new Exception("Unable to create new case with PMFNewCase().");
} 
Then check the value of the "__ERROR__" system variable.

By the way, I have created a custom REST endpoint to change the status of cases from TO_DO to DRAFT and vice versa:
(36 KiB) Downloaded 292 times
(if you have imported an previous version of this plugin, then first delete it, before importing this version).

here is the endpoint:
http://{domain-or-ip}/api/1.0/{workspace}/extrarest/case/status/{app_uid}

For example, to change a case's status from DRAFT to TO_DO:
Code: Select all
$caseId = '7647950535a9f46ade01ab3092163527';
$url = "http://pm.example.com/api/1.0/workflow/extrarest/case/status/$caseId";
$aVars = array(
   'status' => 'TO_DO'
);
$oRet = pmRestRequest("PUT", $url, $aVars, $oToken->access_token); 
User avatar
By amosbatto
#813850
In your env.ini file, add this line:
Code: Select all
debug = 1
Then, any Exceptions that you throw in your trigger code will be logged to the file:
workflow/public_html/php_errors.log
You can view the error file by directing your web browser to:
http://{your-pm-domain}/php_errors.log

Web3 development encompasses creating decentralize[…]

The Upland Clone Script, offered by Dappsfirm, rep[…]

Dappsfirm offers a bet365 clone script that mirror[…]

🚀 Tauchen Sie mit Immediate Alora AI in die Welt d[…]