0

I have been trying to assign users after one step to another using triggers. I queried the users from the department and then stored it in an array to assign in "Assignment Rules" in the next step. The code is as follows:

$selectedDepartment=@@departmentToImplement;
$query = executeQuery("
SELECT USR_UID FROM `users` u
   INNER JOIN department dep ON u.DEP_UID = dep.DEP_UID
   WHERE dep.DEP_UID ='".$selectedDepartment."';
");
$result = executeQuery($query);
if (empty($result)) {
    throw new Exception("Query returned no results");
}
elseif (is_array($result) and count($result) >0) {
    $userArr = array(); // CREATE ARRAY OF USERS
    foreach ($result as $row) {
        $userUID = $row['USR_UID'];
        //array_push($userArr, $userUID); // APPARENTLY THIS METHOD IS SLOW
        $userArr[] = $userUID; // THIS IS FASTER
    }
    @=departmentUsers = $userArr;
    
}

I pass/fire this trigger on the previous step in "Before Routing" and in the next step I want to use "Self Service Value Based Assignment" and pass on teh variable @=departmentUsers which i got from the trigger. I am thinking of using group and the trigger should make a group and that should be passed on in Assignment Rules but i don't know the last step. Any help would be appreciated.

Sharklash
  • 31
  • 1
  • 4

1 Answers1

0
$selectedDepartment=@@departmentToImplement;
$query = executeQuery("
    SELECT USR_UID FROM `users` u
    INNER JOIN department dep ON u.DEP_UID = dep.DEP_UID
    WHERE dep.DEP_UID ='".$selectedDepartment."';
");

if (empty($query)) {
    throw new Exception("Query returned no results");
}

elseif (is_array($query) and count($query) >0) {    
    $userArr = array(); // CREATE ARRAY OF USERS
    foreach ($query as $usr) {
        $userUID = $usr['USR_UID'];
        $userArr[]=$userUID;
    }

    @=listOfUsers = $userArr;
    json_encode(array_values(@=listOfUsers));
}   
Sharklash
  • 31
  • 1
  • 4