GetUserNames
- Last UpdatedOct 29, 2026
- 2 minute read
GetUserNames is a built-in function that gets a list of users that match a specified type and then stores the list in an array tag.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
GetUserNames |
Security |
Synchronous |
No |
Supported |
Supported |
Not supported |
Executed on Server |
Not supported |
Syntax
GetUserNames("tagUsers",optNumUserType,"opttagGroups")
tagUsers
The name of the array tag (String type) that will receive the list of users, starting at array position 0.
Note: If this parameter is enclosed in quotes, the string literal will be used. Otherwise, the value of the tag/expression will be used.
optNumUserType
A numeric flag that indicates the type of users to get:
|
Value |
Description |
|---|---|
|
0 |
All users |
|
1 |
Only users that have the Runtime user option selected |
|
2 |
Only users that do not have the Runtime user option selected |
The Runtime user option is a setting in the User Account dialog, in the project security system. It indicates that the user can be affected during run time by the Security functions, including this one. It is selected automatically if a user is created during run time โ for example, by calling the CreateUser function โ but it can also be selected or cleared manually. For more information, see Creating and configuring users.
This parameter is optional; if no value is specified, the default value is 0.
optTagGroups
The name of the array tag (String type) that will receive a list of the user groups to which the users belong, starting at array position 0. Each user's group(s) will be written to the corresponding array position. For example, for the user stored in MyUsersArray[5], its group(s) are stored in MyGroupsArray[5].
Note: If this parameter is enclosed in quotes, the string literal will be used. Otherwise, the value of the tag/expression will be used.
This parameter is optional; if no value is specified, the list of user groups will not be saved.
Returned value
This function returns the number of users that match the specified type, or a negative number that can be one of the following:
|
Value |
Description |
|---|---|
|
-1 |
Invalid number of parameters. |
|
-2 |
tagUsers is invalid. |
|
-3 |
optNumUserType is invalid. |
|
-4 |
optTagGroups is invalid. |
|
-5 |
Error, function cannot be called in the Thin Client. |
Examples
Get all users, and then store the user names in MyUsersArray:
GetUserNames("MyUsersArray")
Get all users that have the Runtime user option selected, and then store the user names in MyUsersArray:
GetUserNames("MyUsersArray",1)
Get all users that do not have the Runtime user option selected, store the user names in MyUsersArray, and store the corresponding group names in MyGroupsArray:
GetUserNames("MyUsersArray",2,"MyGroupsArray")