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 sujittra
#823105
How to assignment to 6 users

Is this code that right?
@@assignedUsers = array(
"a", //username of a
"b" //username of b
"c", //username of c
"d" //username of d
"e", //username of e
"f" //username of f
)

thank you.
User avatar
By amosbatto
#823112
Are you using a task with Self Service Value Based Assignment ?
If so, then your array needs to contain the unique IDs of the users.

The easiest way to do this is to create a group which contains the 6 users. Then use PMFGetGroupUID() and PMFGetGroupUsers() to get the list of users in the group and assign their unique IDs to the variable used by Self Service Value Based Assignment.

For example, if your group is named "Approvers", then create the following trigger to populate the array used by Self Service Value Based Assignment:
Code: Select all
$groupName = "Approvers";
$groupId = PMFGetGroupUID($groupName);
if (empty($groupId)) {
  throw new Exception("Group '$groupName' doesn't exist.");
}
$aUsers = PMFGetGroupUsers($groupId);
@=availableUsers = array();

foreach ($aUsers as $aUser) {
     @=availableUsers[] = $aUser['USR_UID'];
}
Set this trigger to fire before assignment in the task before the task with Self Service Value Based Assignment. In the properties of the task, set it to use the @@availableUsers variable.
By sujittra
#823124
Warning: trim() expects parameter 1 to be string, array given in C:\Bitnami\processmaker-3.2.1-0\apps\processmaker\htdocs\workflow\engine\classes\class.case.php on line 985

Warning: trim() expects parameter 1 to be string, array given in C:\Bitnami\processmaker-3.2.1-0\apps\processmaker\htdocs\workflow\engine\classes\class.case.php on line 985
User avatar
By michaelg4s
#823701
Hi Amos,

I'm trying to do something similar - I want to assign users based on them being associated to an entity or company. Here is my code:
Code: Select all
$entity = @@entity;

$userQuery = "SELECT USR_UID FROM PMT_ROCC_RECON_MANAGER WHERE ENTITY_ID = '$entity'";

$result = executeQuery($query);
if (empty($result)) {
	throw new Exception("Query returned no results: $userQuery");
}

$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
}

@@inCountryCheckUserArray = $userArr;
When I run this code in the debugger I get the following error:
Code: Select all
Invalid argument supplied for foreach() (line 265):
Which tells me that the result is not an array! I have no idea what to make of this!

I've confirmed that there are two entries in the PMT_ROCC_RECON_MANAGER table, both of which are applicable to the test case.
User avatar
By michaelg4s
#823702
I've just made the following update, going to test it now:
Code: Select all
$entity = @@entity;

$userQuery = "SELECT USR_UID FROM PMT_ROCC_RECON_MANAGER WHERE ENTITY_ID = '$entity'";

$result = executeQuery($query);
if (empty($result)) {
	throw new Exception("Query returned no results: $userQuery");
} 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
	}
	
	@=inCountryCheckUserArray = $userArr;
}
User avatar
By michaelg4s
#823704
michaelg4s wrote: Tue Apr 02, 2019 4:04 am I've just made the following update, going to test it now:
Code: Select all
$entity = @@entity;

$userQuery = "SELECT USR_UID FROM PMT_ROCC_RECON_MANAGER WHERE ENTITY_ID = '$entity'";

$result = executeQuery($query);
if (empty($result)) {
	throw new Exception("Query returned no results: $userQuery");
} 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
	}
	
	@=inCountryCheckUserArray = $userArr;
}
Very strange! I get the same error, BUT
Code: Select all
is_array($result)
appears to be TRUE.
User avatar
By michaelg4s
#823736
Hi Amos,

You're going to laugh.

I have highlighted the source of the error in the code block below.

It works like a charm now!
michaelg4s wrote: Tue Apr 02, 2019 4:10 am
michaelg4s wrote: Tue Apr 02, 2019 4:04 am I've just made the following update, going to test it now:

$entity = @@entity;

$userQuery = "SELECT USR_UID FROM PMT_ROCC_RECON_MANAGER WHERE ENTITY_ID = '$entity'";

$result = executeQuery($query);
if (empty($result)) {
throw new Exception("Query returned no results: $userQuery");
} 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
}

@=inCountryCheckUserArray = $userArr;
}
Very strange! I get the same error, BUT
Code: Select all
is_array($result)
appears to be TRUE.

Web3 development encompasses creating decentralize[…]

The Upland Clone Script, offered by Dappsfirm, rep[…]

Dappsfirm offers a bet365 clone script that mirror[…]

🚀 Tauchen Sie mit Immediate Alora AI in die Welt d[…]