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 Stefan71
#813955
Hi all,
I want to create an sql query over users - table and assign the result to next step parallel task. I believe I have to somehow convert result of query to user array. Any help would be nice.

best regards.
User avatar
By amosbatto
#813962
If you want to create array of the users for assignment in a task with a parallel marker, then the trigger code would be something like this:
Code: Select all
$sql = "SELECT USR_UID FROM USERS";
$aUsers = executeQuery($sql)
@=userList = array();
foreach ($aUsers as $aUser) {
   @=userList[] = $aUser['USR_UID'];
} 
where @@userList is the variable for user assignment.

You can add a WHERE clause to your query.
By Stefan71
#813970
I tried your code, I get following error:

The activity act_uid: "1518537455ac7720138f2e6057468491", has an invalid user-data in "userList" or this variable doesn't exist for a multi-instance activity
User avatar
By amosbatto
#813985
Oh, I see that I forgot a semicolon in the trigger code.
It should be:
Code: Select all
$sql = "SELECT USR_UID FROM USERS";
$aUsers = executeQuery($sql);
@=userList = array();
foreach ($aUsers as $aUser) {
   @=userList[] = $aUser['USR_UID'];
} 
 
If you turn on Debug Mode in the Process properties you can debug these problems.

Here is a sample process to test it:
(31.96 KiB) Downloaded 236 times
User avatar
By amosbatto
#814035
If you want to assign all the users in a particular group to the task with a parallel marker, you can use this trigger code:
Code: Select all
$groupName = "Approval Group";
$groupId = PMFGetGroupUID($groupName);
if (empty($groupId)) {
  throw new Exception("Group '$groupName' doesn't exist.");
}
$aUsers = PMFGetGroupUsers($groupId);
@=userList = array();

foreach ($aUsers as $aUser) {
   @=userList[] = $aUser['USR_UID'];
} 
What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]