Questions and discussion about using ProcessMaker: user interface, running cases & functionality
#817923
Good morning Amo,

I am using ProcessMaker 3.2.2, I was wondering is it possible to generate the following link in a PHP trigger? Or can I get it from any table in the database?

This link is from ABE function.
Code: Select all
https://localhost/syscos/en/neoclassic/services/ActionsByEmail?ACTION=o9Wfz5Xmp3Gysdasd&APP_UID=Z5ZhomSjamKlqZPTp2ppqGLRZZZoommjZGigpmmmqms&DEL_INDEX=Zg&FIELD=ptig0asdasdsa5nLd5aeo6JY&VALUE=dtKe0pnloVDd7asdasd5me5A&ABER=aJNpoGKsbWsdadadTp2ppqGSmbJljo2GjaWepp2Ggp2k
Thanks,
Yuan
#817926
amosbatto wrote: Mon Nov 19, 2018 6:33 pm It looks like the GET values in the URL are encrypted. Can you provide a screenshot of where that link is used?
Hi Amo,

This link is for the "approve" button, and I was wondering can I get this link in the trigger and save into another table?

Thanks,
Yuan
Attachments
2018-11-20_9-39-56.jpg
2018-11-20_9-39-56.jpg (32.64 KiB) Viewed 8725 times
#817934
cosyxu wrote:Hi Amo,

Can I also ask how to set value for a radio button in a php trigger?

I have create a trigger before a dyanform to setup this value but it doesn't work....

This is my trigger:
Code: Select all
 @@approval = 'Yes';
And then in the dyanform, I still get a emply value for the variable "approval"...
In the list of options for your radio button, you need to have an option whose key is "Yes". You probably misspelled it. Remember that it is case sensitive.

I just tried it in PM 3.2.3 and it works. See this process for an example:
(23.75 KiB) Downloaded 262 times
I
#818015
cosyxu wrote: Mon Nov 19, 2018 5:57 pm Good morning Amo,

I am using ProcessMaker 3.2.2, I was wondering is it possible to generate the following link in a PHP trigger? Or can I get it from any table in the database?

This link is from ABE function.
Code: Select all
https://localhost/syscos/en/neoclassic/services/ActionsByEmail?ACTION=o9Wfz5Xmp3Gysdasd&APP_UID=Z5ZhomSjamKlqZPTp2ppqGLRZZZoommjZGigpmmmqms&DEL_INDEX=Zg&FIELD=ptig0asdasdsa5nLd5aeo6JY&VALUE=dtKe0pnloVDd7asdasd5me5A&ABER=aJNpoGKsbWsdadadTp2ppqGSmbJljo2GjaWepp2Ggp2k
Thanks,
Yuan
I finally figured this out. You totally screwed me up by corrupting the URL. When I tried to decrypt your URL in ProcessMaker, it threw an error and I couldn't figure out why. I finally figured out that you purposely changed the encrypted characters, which was causing the errors when decrypting. You really are paranoid. :-)

OK, create a trigger like this:
Code: Select all
$g = new \G();
print "<pre>Original URL:\n".
"https://localhost/syscos/en/neoclassic/services/ActionsByEmail?ACTION=o9Wfz5Xmp3Gysdasd&APP_UID=Z5ZhomSjamKlqZPTp2ppqGLRZZZoommjZGigpmmmqms&DEL_INDEX=Zg&FIELD=ptig0asdasdsa5nLd5aeo6JY&VALUE=dtKe0pnloVDd7asdasd5me5A&ABER=aJNpoGKsbWsdadadTp2ppqGSmbJljo2GjaWepp2Ggp2k\n\n";

print "Decrypted URL:\nhttps://localhost/syscos/en/neoclassic/services/ActionsByEmail".
	"?ACTION=".$g->decrypt(urldecode(utf8_encode("o9Wfz5Xmp3Gysdasd")), URL_KEY).
	"&APP_UID=".$g->decrypt(urldecode(utf8_encode("Z5ZhomSjamKlqZPTp2ppqGLRZZZoommjZGigpmmmqms")), URL_KEY).
	"&DEL_INDEX=".$g->decrypt(urldecode(utf8_encode("Zg")), URL_KEY).
	"&FIELD=".$g->decrypt(urldecode(utf8_encode("ptig0asdasdsa5nLd5aeo6JY")), URL_KEY).
	"&VALUE=".$g->decrypt(urldecode(utf8_encode("dtKe0pnloVDd7asdasd5me5A")), URL_KEY).
	"&ABER=".$g->decrypt(urldecode(utf8_encode("aJNpoGKsbWsdadadTp2ppqGSmbJljo2GjaWepp2Ggp2k")), URL_KEY);
die;
This will show you the decrypted values in the URL. You will have to change the strings to match your URL to see the original values.

Once you know the original values, then you can construct the URL like this:
Code: Select all
$encryptedUrl = "https://localhost/syscos/en/neoclassic/services/ActionsByEmail".
	"?ACTION=".$g->encrypt("processABE", URL_KEY).
	"&APP_UID=".$g->encrypt($caseId, URL_KEY).
	"&DEL_INDEX=".$g->encrypt($index, URL_KEY).
	"&FIELD=".$g->encrypt($fieldId, URL_KEY).
	"&VALUE=".$g->encrypt($fieldValue, URL_KEY).
	"&ABER=".$g->encrypt($abeResponse, URL_KEY);
//Execute the URL:
header("location: $encryptedUrl");
#818021
amosbatto wrote: Wed Nov 21, 2018 10:07 am
cosyxu wrote: Mon Nov 19, 2018 5:57 pm Good morning Amo,

I am using ProcessMaker 3.2.2, I was wondering is it possible to generate the following link in a PHP trigger? Or can I get it from any table in the database?

This link is from ABE function.
Code: Select all
https://localhost/syscos/en/neoclassic/services/ActionsByEmail?ACTION=o9Wfz5Xmp3Gysdasd&APP_UID=Z5ZhomSjamKlqZPTp2ppqGLRZZZoommjZGigpmmmqms&DEL_INDEX=Zg&FIELD=ptig0asdasdsa5nLd5aeo6JY&VALUE=dtKe0pnloVDd7asdasd5me5A&ABER=aJNpoGKsbWsdadadTp2ppqGSmbJljo2GjaWepp2Ggp2k
Thanks,
Yuan
I finally figured this out. You totally screwed me up by corrupting the URL. When I tried to decrypt your URL in ProcessMaker, it threw an error and I couldn't figure out why. I finally figured out that you purposely changed the encrypted characters, which was causing the errors when decrypting. You really are paranoid. :-)

OK, create a trigger like this:
Code: Select all
$g = new \G();
print "<pre>Original URL:\n".
"https://localhost/syscos/en/neoclassic/services/ActionsByEmail?ACTION=o9Wfz5Xmp3Gysdasd&APP_UID=Z5ZhomSjamKlqZPTp2ppqGLRZZZoommjZGigpmmmqms&DEL_INDEX=Zg&FIELD=ptig0asdasdsa5nLd5aeo6JY&VALUE=dtKe0pnloVDd7asdasd5me5A&ABER=aJNpoGKsbWsdadadTp2ppqGSmbJljo2GjaWepp2Ggp2k\n\n";

print "Decrypted URL:\nhttps://localhost/syscos/en/neoclassic/services/ActionsByEmail".
	"?ACTION=".$g->decrypt(urldecode(utf8_encode("o9Wfz5Xmp3Gysdasd")), URL_KEY).
	"&APP_UID=".$g->decrypt(urldecode(utf8_encode("Z5ZhomSjamKlqZPTp2ppqGLRZZZoommjZGigpmmmqms")), URL_KEY).
	"&DEL_INDEX=".$g->decrypt(urldecode(utf8_encode("Zg")), URL_KEY).
	"&FIELD=".$g->decrypt(urldecode(utf8_encode("ptig0asdasdsa5nLd5aeo6JY")), URL_KEY).
	"&VALUE=".$g->decrypt(urldecode(utf8_encode("dtKe0pnloVDd7asdasd5me5A")), URL_KEY).
	"&ABER=".$g->decrypt(urldecode(utf8_encode("aJNpoGKsbWsdadadTp2ppqGSmbJljo2GjaWepp2Ggp2k")), URL_KEY);
die;
This will show you the decrypted values in the URL. You will have to change the strings to match your URL to see the original values.

Once you know the original values, then you can construct the URL like this:
Code: Select all
$encryptedUrl = "https://localhost/syscos/en/neoclassic/services/ActionsByEmail".
	"?ACTION=".$g->encrypt("processABE", URL_KEY).
	"&APP_UID=".$g->encrypt($caseId, URL_KEY).
	"&DEL_INDEX=".$g->encrypt($index, URL_KEY).
	"&FIELD=".$g->encrypt($fieldId, URL_KEY).
	"&VALUE=".$g->encrypt($fieldValue, URL_KEY).
	"&ABER=".$g->encrypt($abeResponse, URL_KEY);
//Execute the URL:
header("location: $encryptedUrl");
Hi Amo,

Yes, I did change some the characters for the encrypted string, and sorry for making you confused. :P

Thanks for the solution.

I just wondering where should I put this trigger in my process. For example, when I create the ABE task (Manager Approval), can I generate this link before the ABE task? or I need a parallel gateway to run a trigger to generate the above link and pass that link into our another system where the manager can click this link to trigger the next step after the ABE task. Will this work?

Thanks,
Yuan
#818029
If you look at the code of workflow/engine/methods/services/ActionsByEmail.php, you will see that the field and its value are stored in the database as a case variable and then the case is routed to the next task.

You can execute this URL in a trigger with the header("location: URL") function or use cURL if you don't want to redirect to the page. See: https://stackoverflow.com/questions/312 ... background

You can execute this URL in an external program or in the trigger in another case. If the case has already been routed beyond the index number, then you will see an error, but has it won't harm anything. If you are executing this URL in the a trigger in the current task in the current case, then it should be followed by a die() so that it doesn't try to route to the next task twice (which will case an error):
header("Location: $abeUrl");
die();

However, there is no reason to use this URL if calling it in the current task in the current case in my opinion, since you can do exactly the same thing with:
Code: Select all
$aVars = array(
    "yourfield" => $yourFieldValue
);
PMFSendVariables(@@APPLICATION, $aVars);
PMFDerivateCase(@@APPLICATION, @%INDEX);
header("Location: casesListExtJsRedirector");
die();
#822445
Hi Amo,

Thanks for the advice. It seems our requirement has been changed a bit.

In our workflow, we have a task which use "Link to fill a form" function, which will send the following link to the assigned user's mailbox.
Code: Select all
https://testbpm1/syscos/en/neoclassic/services/ActionsByEmailDataForm?APP_UID=a5NjomijaGGpqZSe1phv12aeY5mVpWCjbWemqGWhrW4&DEL_INDEX=ZQ&DYN_UID=bJlgoGGra2ChqZOh2GZqopfQl5dp0WajZWamqGKlqGc&ABER=Z5VpoGGlbGShqZShpmdr1ZOhbJRnoGmja2elq2aepWU&BROWSER_TIME_ZONE_OFFSET=39600
But we want to show this link in our external application, therefore is there any way that we can pass the above URL from processmaker to database of an external application so it can show in the application?

Thanks,
Yuan
#822447
cosyxu wrote: But we want to show this link in our external application, therefore is there any way that we can pass the above URL from processmaker to database of an external application so it can show in the application?
Instead of redirecting to the web page with:
header("location: $encryptedUrl");
You can use executeQuery() to write $encryptedUrl to your database.
#822449
amosbatto wrote: Thu Jan 17, 2019 9:48 pm
cosyxu wrote: But we want to show this link in our external application, therefore is there any way that we can pass the above URL from processmaker to database of an external application so it can show in the application?
Instead of redirecting to the web page with:
header("location: $encryptedUrl");
You can use executeQuery() to write $encryptedUrl to your database.

Hi Amo,

Thanks for your prompt reply.

Yes I know how to pass the string into the database, but I really don't know how to generate the $encryptedUrl.

For example, I create a parallel task(script task) when it routes to the Link to fill a form task.

How can I structure this link? It seems that I need to get the following variable:

APP_UID,
DYN_UID,
DEL_INDEX,
ABER

Any ideas how to get those variables?

Thanks
Yuan
#822453
The URL is generated in the file workflow/engine/classes/ActionsByEmailCoreClass.php.

$APP_UID is the case ID, which you can get from the @@APPLICATION system variable for the current case (or from the APPLICATION.APP_UID in the database).

$ABER is the encrypted Actions by Email Request ID which you can get from the ABE_REQUESTS.ABE_REQ_UID field in the database. You can look this up with a trigger for the current case:
Code: Select all
//get this from the ABE_CONFIGURATION.ABE_UID field in the database
//you only need to use this if you are using more than one action by email in the same task. 
//If you only have one in this task, then leave it out of the query
$abeId = 'XXXXXXXXXXXXXXXXXXXXXX';  

$caseId = @@APPLICATION;
$index = @%INDEX;
$sql = 'SELECT * FROM ABE_REQUESTS WHERE APP_UID='$caseId' AND DEL_INDEX=$index AND ABE_UID='$abeId'"; 
$result = executeQuery($sql);
if (empty($result)) {
   throw new Exception("Unable to find actions by email request in database: $sql");
}
$g = new \G();
$aber = $g->encrypt($result[1]['ABE_REQ_UID'], URL_KEY, true);
#822456
amosbatto wrote: Fri Jan 18, 2019 12:33 am The URL is generated in the file workflow/engine/classes/ActionsByEmailCoreClass.php.

$APP_UID is the case ID, which you can get from the @@APPLICATION system variable for the current case (or from the APPLICATION.APP_UID in the database).

$ABER is the encrypted Actions by Email Request ID which you can get from the ABE_REQUESTS.ABE_REQ_UID field in the database. You can look this up with a trigger for the current case:
Code: Select all
//get this from the ABE_CONFIGURATION.ABE_UID field in the database
//you only need to use this if you are using more than one action by email in the same task. 
//If you only have one in this task, then leave it out of the query
$abeId = 'XXXXXXXXXXXXXXXXXXXXXX';  

$caseId = @@APPLICATION;
$index = @%INDEX;
$sql = 'SELECT * FROM ABE_REQUESTS WHERE APP_UID='$caseId' AND DEL_INDEX=$index AND ABE_UID='$abeId'"; 
$result = executeQuery($sql);
if (empty($result)) {
   throw new Exception("Unable to find actions by email request in database: $sql");
}
$g = new \G();
$aber = $g->encrypt($result[1]['ABE_REQ_UID'], URL_KEY, true);
Hi Amo,

Thank you for your comments.

So based on the code above.

I think this will work:
Code: Select all
$task_id = @@TASK;
$caseId  = @@APPLICATION;
$index 	 = @%INDEX
//->this may need to be static
$abe_uid = executeQuery("SELECT ABE_UID FROM wf_cos.abe_configuration WHERE TAS_UID='$task_id'");               
$abe_req_uid = executeQuery("SELECT ABE_REQ_UID FROM wf_cos.abe_requests WHERE ABE_UID= '$abe_uid' AND APP_UID = '$caseId'");
$dyn_uid   	 = '9604187015b4c110fcd49e6016641832'

$encryptedUrl = 'https://testbpm1/syscos/en/neoclassic/services/ActionsByEmailDataForm' . 
'?APP_UID='   . $g->encrypt($caseId, URL_KEY) . 
'&DEL_INDEX=' . $g->encrypt($index, URL_KEY) . 
'&DYN_UID='   . $g->encrypt($dyn_uid, URL_KEY) .
'&ABER=' 	  . $g->encrypt($abe_req_uid, URL_KEY) .
'&BROWSER_TIME_ZONE_OFFSET=39600';
And this trigger will be a parallel script together with the ABE task. I will try this next week.

Thanks again,
Yuan
#822469
Hi Amo,

Just let you know that it works.

Here is my code to generating the ABE URL
Code: Select all
//task id can't be dynamic because this task id is refered to the 
//trigger 6141052245c4150576f30c2044669943
//not the ABE Task 2566223145c4150305ac6f1019922580
$task_id = '2566223145c4150305ac6f1019922580'; 
$caseId  = @@APPLICATION;
//this can't be dynamic
$index = 2;
$dyn_uid = '5335388185c44efdee85e49036143801';
$db = '92313726387267hjhj98989d8d8s769d7g63j'; //unique ID of database connection

$result1 = executeQuery("SELECT * FROM abe_configuration WHERE TAS_UID='2566223145c4150305ac6f1019922580'", $db);
if (is_array($result1) and count($result1) > 0) {
    @@temp1 = $result1[1]['ABE_UID'];
    $temp_abe_uid = $result1[1]['ABE_UID'];
}

$result2 = executeQuery("SELECT * FROM abe_requests WHERE ABE_UID= '$temp_abe_uid' AND APP_UID = '$caseId'", $db);
if (is_array($result2) and count($result2) > 0) {
    @@temp2 = $result2[1]['ABE_REQ_UID'];
    $temp_abe_req_uid = $result2[1]['ABE_REQ_UID'];
 
}

$g = new \G();

$encryptedUrl = 'https://testbpm1/syswf/en/neoclassic/services/ActionsByEmailDataForm' . 
'?APP_UID='   . $g->encrypt($caseId, URL_KEY) . 
'&DEL_INDEX=' . $g->encrypt($index, URL_KEY) . 
'&DYN_UID='   . $g->encrypt($dyn_uid, URL_KEY) .
'&ABER=' 	  . $g->encrypt($temp_abe_req_uid, URL_KEY) .
'&BROWSER_TIME_ZONE_OFFSET=39600';

@@linkaddress = $encryptedUrl;
and my process map.

Thanks for your help.

Regards,
Yuan
Attachments
structure link.jpg
structure link.jpg (17.22 KiB) Viewed 8412 times
#822484
amosbatto wrote: Tue Jan 22, 2019 12:30 am You can make it a little faster by combining your 2 database queries into 1 query.
Code: Select all
executeQuery("SELECT AR.* FROM abe_configuration AC, abe_requests AR  WHERE   
   AC.TAS_UID='2566223145c4150305ac6f1019922580' AND AC.ABE_UID=AR.ABE_UID AND 
   AR.APP_UID = '$caseId'", $db);
Thanks for the improvement, that's great. :D

Regards,
Yuan
#822755
amosbatto wrote: Tue Jan 22, 2019 12:30 am You can make it a little faster by combining your 2 database queries into 1 query.
Code: Select all
executeQuery("SELECT AR.* FROM abe_configuration AC, abe_requests AR  WHERE   
   AC.TAS_UID='2566223145c4150305ac6f1019922580' AND AC.ABE_UID=AR.ABE_UID AND 
   AR.APP_UID = '$caseId'", $db);
Hi Amo,

Just wondering, is there any way that I can shorten following link?

https://testbpm1/syscos/en/neoclassic/s ... FSET=39600

For example, to change it likes https://bit.3HHFV.

Thanks,
Yuan
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[…]