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

Moderator: ArturoRobles

#827332
Hello everybody,

I have to calculate a specific variable for a user logged according to his groups of membership.

I try to do it with this code but $query1 part seams to doesn't work (if I replace $result1 by a list of group id in $query2, it works as I want).

$reglenommage="RVD_NAT_DA_H66";//namerule
[email protected]@USER_LOGGED;//user_uid of user logged
$query1= "select distinct GRP_UID from GROUP_USER where USR_UID=$UserID";//groups of user logged
$result1= executeQuery($query1);
$query2= "select distinct GRP_TITLE, GRP_UID from GROUPWF where GRP_TITLE like '$reglenommage%' and GRP_UID in($result1)";//groups matching to namerule within groups of user logged
$result2=executeQuery($query2);
$GroupTitle=$result2[1]['GRP_TITLE'];//first result matching
$region = substr($GroupTitle, 11, 6);//truncate group name
@@INIT_CODE_REGION=$region;

Could you help me, please ?
#827333
Hi,
Your code should be well-written to make it easier for you to understand and troubleshoot.
Please check this code:
Code: Select all
$reglenommage = "RVD_NAT_DA_H66";	//namerule
$UserID = @@USER_LOGGED;			//user_uid of user logged

$query = '
	select distinct GRP_UID
	from GROUP_USER
	where USR_UID = "'.$UserID.'";
';
$result = executeQuery($query);

$temp = [];
foreach($result as $row)
	array_push($temp, $row['GRP_UID']);

if(count($temp) > 0){
	$query = '
		select distinct GRP_TITLE, GRP_UID
		from GROUPWF
		where GRP_TITLE like "'.$reglenommage.'%" and GRP_UID in("'.implode('" , "', $temp).'");
	';
	$result = executeQuery($query);
	if(is_array($result) && count($result) > 0){
		$GroupTitle = $result[1]['GRP_TITLE'];	//first result matching
		$region = substr($GroupTitle, 11, 6);	//truncate group name
		@@INIT_CODE_REGION = $region;
	}
}
https://www.youtube.com/channel/UCYiyz1 ... 1iw/videos
https://www.linkedin.com/in/pmlearning/
Thanks
Manual email send out did not run.

Dear All, Sometimes email stuck in pending when p[…]

DELETE A OUTPUT DOCUMENT

I solve the problem using this trigger $caseId =[…]

First off I am new to processmaker. I am trying to[…]

Total of grid in integer

Hi, Is there any better way to do it instead of c[…]