Group Functions

PMFGroupList()

PMFGroupList() returns a list of groups in the current workspace sorted in alphabetical order. In order to use this function, the logged-in user must have the PM_USERS permission in his/her role.

array PMFGroupList(string $regEx = null, int $start = null, int $limit = null)

Parameters:

  • string regEx: Optional. A regular expression used to search for groups by their name. If this parameter is not included, all the groups are returned.
  • int start: Optional. The number in the list of groups where to start returning groups.
  • int limit: Optional. The maximum number of groups to return.

Return Value:

An array of groups, with the following structure:

[0] array ( associative array ( [string guid] [string name] ) ) ...

If no group is found, an empty array is returned.

Where:

  • string guid: The unique ID of a group.
  • string name: The name of a group.

Examples:

  • $array = PMFGroupList(); Returns all the groups in the current workspace.
  • $array = PMFGroupList('(Ad)+') Returns all groups starting with "Ad".
  • $array = PMFGroupList('', 3, 4); Returns all groups from the third register and the following 4 items.
  • $array = PMFGroupList('(Ad)+', 2, 5); Returns all groups starting with Ad, but this time from the second register and the following 5 items.

PMFGetGroupUID()

PMFGetGroupUID() retrieves the unique ID of a group using the group name.

string PMFGetGroupUID(string groupName)

Parameters:

  • string groupName: The name of the group. Note that the name is case sensitive.

Return value:

  • string: The function returns the unique ID of the group or false if the group name is not found.

Example:

This trigger code looks up the ID of a group with the PMFGetGroupUID() function and then uses that ID to retrieve a list of users in that group with the PMFGetGroupUsers() function. Then, it places the IDs and names of the users in an array which can be used as the array variable for the list of options in a dropdown box.

$groupName = "Approval Group";
$groupId = PMFGetGroupUID($groupName);
if (empty($groupId)) {
  throw new Exception("Group '$groupName' doesn't exist.");
}
$aUsers = PMFGetGroupUsers($groupId);
@=availableUsers = array();

foreach ($aUsers as $aUser) {
   $fullName = $aUser['USR_FIRSTNAME'] .' '. $aUser['USR_LASTNAME'];
   @=availableUsers[] = array($aUser['USR_UID'], $fullName);
}

PMFGetGroupName()

PMFGetGroupName() retrieves the name of a group using the unique ID of the group and given language.

string PMFGetGroupName(string groupUID, string Language)

Parameters:

  • string groupUID: The unique ID of the group, which can be found in the following ways:
  • string Language: Optional parameter. The language in which the group name will be retrieved. If not specified then the default system language is used.

Note: Please take into account that returned values directly depend on the current data stored in the wf_<WORKSPACE>.CONTENT table, and more specifically records related to group titles (CON_CATEGORY = GRP_TITLE).

Return value:

  • string: The function returns the name of the group.

Example:

@@groupName = PMFGetGroupName(@@GROUP,'es');

The returned value stored in @@groupName will be "Empleados".

PMFGetGroupUsers()

PMFGetGroupUsers() retrieves the users who are members of a group.

array PMFGetGroupUsers(string groupUID)

Parameters:

  • string groupUID: The unique ID of a group, which can be found in the following ways:
    • Use the PMFGroupList() or WSGroupList() functions or the groupList() web service.
    • Query the wf_<WORKSPACE>.GROUPWF.GRP_UID field in the database.
    • Use the query:
      SELECT CON_VALUE, CON_ID FROM CONTENT WHERE CON_CATEGORY='GRP_TITLE'

Return Value:

An array of associative arrays; each one of these arrays contains information about each user included in the group. The array has the following structure:

[0] array ( associative array ( [property1] => value [property2] => value [property3] => value ... ) ) [1] array ( associative array ( [property1] => value [property2] => value [property3] => value ... ) ...

Example:

@@UsersList = PMFGetGroupUsers("8511196744b6380deb57b69039061394");

The variable @@UsersList will obtain all the information about the users of the group. The return value will show:

Array ( [0] => Array ( [USR_UID] => 41648276456d8a8acd76857021709199 [USR_USERNAME] => daniela [USR_PASSWORD] => aa41ab4c932bdcc5246171e3a0aed710 [USR_FIRSTNAME] => Daniela [USR_LASTNAME] => Martinez [USR_EMAIL] => email@engineer.com [USR_DUE_DATE] => 2017-03-03 [USR_CREATE_DATE] => 2016-03-03 21:12:12 [USR_UPDATE_DATE] => 2016-03-03 21:12:12 [USR_STATUS] => ACTIVE [USR_COUNTRY] => BO [USR_CITY] => L [USR_LOCATION] => LPB [USR_ADDRESS] => [USR_PHONE] => [ [USR_FAX] => [USR_CELLULAR] => [USR_ZIP_CODE] => 2254 [DEP_UID] => 77449242256d8a8dbe3fa03081252723 [USR_POSITION] => [USR_RESUME] => [USR_BIRTHDAY] => 2016-03-03 [USR_ROLE] => PROCESSMAKER_ADMIN [USR_REPORTS_TO] => 41648276456d8a8acd76857021709199 [USR_REPLACED_BY] => 00000000000000000000000000000001 [USR_UX] => NORMAL [USR_TOTAL_INBOX] => 5 [USR_TOTAL_DRAFT] => 1 [USR_TOTAL_CANCELLED] => 0 [USR_TOTAL_PARTICIPATED] => 6 [USR_TOTAL_PAUSED] => 0 [USR_TOTAL_COMPLETED] => 0 [USR_TOTAL_UNASSIGNED] => 0 [USR_COST_BY_HOUR] => 10.00 [USR_UNIT_COST] => $ [USR_PMDRIVE_FOLDER_UID] => [USR_BOOKMARK_START_CASES] => [USR_TIME_ZONE] => America/New_York [USR_DEFAULT_LANG] => en ) [1] => Array ( [USR_UID] => 64057912456ddf2b679e620007773823 [USR_USERNAME] => monica [USR_PASSWORD] => 3250fc092f6026b2cf0333f63644cb6e [USR_FIRSTNAME] => Monica [USR_LASTNAME] => Roddeford [USR_EMAIL] => d.callisaya@hotmail.com [USR_DUE_DATE] => 2017-03-07 [USR_CREATE_DATE] => 2016-01-17 21:29:26 [USR_UPDATE_DATE] => 2016-03-05 11:25:03 [USR_STATUS] => ACTIVE [USR_COUNTRY] => [USR_CITY] => [USR_LOCATION] => [USR_ADDRESS] => [USR_PHONE] => [USR_FAX] => [USR_CELLULAR] => [USR_ZIP_CODE] => [DEP_UID] => [USR_POSITION] => [USR_RESUME] => [USR_BIRTHDAY] => 2016-03-07 [USR_ROLE] => PROCESSMAKER_OPERATOR [USR_REPORTS_TO] => [USR_REPLACED_BY] => [USR_UX] => NORMAL [USR_TOTAL_INBOX] => 35 [USR_TOTAL_DRAFT] => 4 [USR_TOTAL_CANCELLED] => 0 [USR_TOTAL_PARTICIPATED] => 87 [USR_TOTAL_PAUSED] => 5 [USR_TOTAL_COMPLETED] => 10 [USR_TOTAL_UNASSIGNED] => 0 [USR_COST_BY_HOUR] => 580.00 [USR_UNIT_COST] => Euro [USR_PMDRIVE_FOLDER_UID] => [USR_BOOKMARK_START_CASES] => [USR_TIME_ZONE] => America/Anguilla [USR_DEFAULT_LANG] => en ) )

PMFAssignUserToGroup()

PMFAssignUserToGroup() assigns a user to a group. Note that the logged-in user must have the PM_USERS permission in his/her role to be able to assign a user to a group.

int PMFAssignUserToGroup(string userUID, string groupUID)

Parameters:

  • string userUID: The unique ID of the user.
  • string groupUID: The unique ID of the group.

Return Value:

Returns 1 if the user was successfully assigned to the group; otherwise, returns 0 if an error occurred.

Example:

$GroupUID = '8511196744b6380deb57b69039061394';
$var = PMFAssignUserToGroup(@@USER_LOGGED, $GroupUID);
if($var == 0)
    @@text = "It was not assigned";
else
    @@text = "It was assigned";

Where:

  • $GroupUID: The ID of the employee group.
  • @@USER_LOGGED: This is the ID of the user logged in.
  • $var: This function returns 1 if the user was successfully assigned and 0 if not, and will store the return value to confirm the assignment.

PMFRemoveUsersFromGroup()

PMFRemoveUsersFromGroup() removes users from a group. Take into consideration that only roles with the PM_USERS permission will be able to use this function.

int PMFRemoveUsersFromGroup(string groupUID, array usersUID)

Parameters:

  • string groupUID: The unique ID of the group from which the users will be removed. This parameter can be found in the following ways:
    • Use the PMFGroupList() or WSGroupList() functions or the groupList() web service.
    • Query the wf_<WORKSPACE>.GROUPWF.GRP_UID field in the database.
    • Use the query:
      SELECT CON_VALUE, CON_ID FROM CONTENT WHERE CON_CATEGORY='GRP_TITLE'
  • array usersUID: An array of the unique IDs of the users who are going to be removed from the group.

Return Value:
Returns 1 if the user/group was assigned successfully; otherwise, returns 0 if an error occurred.

Example:

@@ReturnValue = PMFRemoveUsersFromGroup("523651123582cafe6735068050719273", array('1338195805812063b044715060827459','2157592775812065fecf8b2028626881'));