Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

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 maabik
#827951
Hi,
I have two tasks A and B as illustrated in the attached file, where task B is assigned to a group named: “Accounting validators” with a self-service method.
When the user validates task A, an email notification is sent to all users of the group “Accounting validators”, for that I did the following inside a trigger:
Code: Select all
$groupName = "WF France GestCtrat Compta Validation 1";
$groupId = PMFGetGroupUID($groupName);
if (empty($groupId)) { 
throw new Exception("Group '$groupName' doesn't exist."); 
}else{
$aUsers = PMFGetGroupUsers($groupId);
foreach ($aUsers as $aUser) {
$res=PMFSendMessage(@@APPLICATION, '', $aUser['USR_EMAIL'] , '', '',$subject, $templateMail,$aFields);
This method is working fine, however, i am looking for a method to dynamically get the group name of the next step without hard code it name in the code?
I am using ProcessMaker Enterprise Edition 3.3.17

Best Regards.
Attachments
Screenshot_1.png
Screenshot_1.png (10.42 KiB) Viewed 943 times
By maabik
#827952
maabik wrote: Mon Apr 27, 2020 7:56 pm Hi,
I have two tasks A and B as illustrated in the attached file, where task B is assigned to a group named: “Accounting validators” with a self-service method.
When the user validates task A, an email notification is sent to all users of the group “Accounting validators”, for that I did the following inside a trigger:
Code: Select all
$groupName = "ccounting validators";
$groupId = PMFGetGroupUID($groupName);
if (empty($groupId)) { 
throw new Exception("Group '$groupName' doesn't exist."); 
}else{
$aUsers = PMFGetGroupUsers($groupId);
foreach ($aUsers as $aUser) {
$res=PMFSendMessage(@@APPLICATION, '', $aUser['USR_EMAIL'] , '', '',$subject, $templateMail,$aFields);
This method is working fine, however, i am looking for a method to dynamically get the group name of the next step without hard code it name in the code?
I am using ProcessMaker Enterprise Edition 3.3.17

Best Regards.
User avatar
By RicardoMG
#827957
Hello!

I understand that you want it to be dynamic to get the group uid, so i found one way to do it.
In your trigger code add the following code in the top:

Code: Select all
//Task's name 
$task_title = 'B';
//process's id
$process = @@PROCESS;
//The variable $result gets the TAS_UID of all the steps of each task of each process
$result = executeQuery("
SELECT TAS_UID 
FROM STEP
WHERE PRO_UID ='$process'");
//We iterate the variable $result to get the uid of each task
foreach ($result as $task_uid) {
	//We get the uid of task B
	$tas_uid = executeQuery("SELECT TAS_UID
	FROM TASK
	WHERE TAS_UID = '$task_uid[TAS_UID]' AND TAS_TITLE = '$task_title'");	
}
//We store in the variable $tas_uid_aux the uid of the task
$tas_uid_aux = $tas_uid[1][TAS_UID];

$g_uid = executeQuery("
	SELECT USR_UID 
	FROM TASK_USER
	WHERE TAS_UID ='$tas_uid_aux'");
//In the variable $group_uid, we obtain the uid of the group of users 
$groupId = $g_uid[1][USR_UID];

$aUsers = PMFGetGroupUsers($groupId);
foreach ($aUsers as $aUser) {
	....

let me know if the code is working without problems

Best regards, Ricardo.
REST API Question

I am currently looking at developing a portlet for[…]

Everybody wants to be famous, but nobody wants to […]

Hi, I attached a sample config file, Please check […]

Error clicking on Participated

Hi, I attached a sample config file, Please check […]