Load Users from SQL
Audience:
Low-code EngineersSkill Prerequisites:
Actions,SQL,User management
Runs a SQL query and adds every user it returns to the context's list of users. Actions that follow, such as Send Email or Grant User Role, can then work on all of those users at once.
It doesn't change the current user. [User:*] tokens still return the values of the user who was current before.
The action is available in Forms, Grids, API endpoints, InfoBox and Scheduler jobs. It works the same way in all of them.
This action requires the Data Integration feature (Standard) to be licensed. If it isn't, the action fails with a message that the feature is unlicensed.
Typical Use Cases
- Send an email to every user who matches a condition, such as everyone in a department
- Grant or revoke a role for a group of users in one step
- Authorize, unauthorize or delete users selected by a query, for example in a scheduled cleanup job
Don't use it to
- Change the current user. Use Load User instead.
- Read user data into tokens or a list. Use Run SQL Query or Create List from SQL instead.
Related Actions
| Action Name | Description |
|---|---|
| Load User | Loads specific users and makes the last one the current user. |
| Send Email | With Send mail to all users checked, sends one email to each user in the list. |
| Grant User Role | Grants roles to the current user and to every user in the list. |
| Revoke User Role | Removes roles from the current user and from every user in the list. |
| Authorize User | Authorizes the current user and every user in the list. |
| Unauthorize User | Unauthorizes the current user and every user in the list. |
| Delete User | Deletes the users in the list. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| SQL Query | The query that returns the users to load. Only the first column is read. It can hold user IDs (numbers), usernames or email addresses, for example SELECT UserID FROM Users WHERE LastName = '[LastName]'. | Yes | empty string | No |
Considerations
- Actions may affect every loaded user. Delete User, Grant User Role, Revoke User Role, Authorize User and Unauthorize User work on the whole list. Test the query first, for example in the SQL Console, so you don't change or delete more users than you meant to.
- Grant, revoke, authorize and unauthorize also affect the current user. Grant User Role, Revoke User Role, Authorize User and Unauthorize User change the current user as well as the users in the list. In a form, that's usually the logged-in user. Only Delete User works on the list alone.
- Loading again adds to the list. Users already in the list, from an earlier Load User or Load Users from SQL, are kept. A user isn't added twice.
- Errors don't stop the actions. If the query fails, or a returned value doesn't match any user, the error is written to the log and the action stops loading. Users read before that row stay in the list, and the next actions still run. Check the log if fewer users were loaded than expected.
- Return only real users. Filter out
NULLvalues and deleted users in the query. A value that doesn't match a user stops the loading, as described above. - Token values are escaped for SQL. Quotes in a token value can't break the query. Unknown tokens, like
[Users], are left as they are, so bracketed table and column names still work. - The query runs on the application's database, with a 10-minute timeout.
- Users are searched on all portals. The first portal with a matching user wins. Join to
UserPortalsin the query if you only want users from one portal. - Inside Execute Actions. When the action runs inside Execute Actions, the list goes back to what it was once those inner actions finish.
- An empty query does nothing.
Examples
To understand how to use the below examples, please see Running Examples.
1. Load all users with a given last name
This action loads every user whose last name matches the LastName field.
{
"Title": "Load Users from SQL",
"ActionType": "LoadUsersFromSql",
"Description": "Load users by last name",
"Parameters": {
"SqlQuery": "SELECT UserID FROM Users WHERE LastName = '[LastName]' AND IsDeleted = 0"
}
}
2. Load the users in a role and grant them the Subscribers role
These actions load every user in the Newsletter role, then grant each of them the Subscribers role with no expiration date. The current user also gets the role.
{
"Title": "Load Users from SQL",
"ActionType": "LoadUsersFromSql",
"Description": "Load users in the Newsletter role",
"Parameters": {
"SqlQuery": "SELECT ur.UserID FROM UserRoles ur INNER JOIN Roles r ON r.RoleID = ur.RoleID WHERE r.RoleName = 'Newsletter'"
}
}
{
"Title": "Grant User Role",
"ActionType": "GrantUserRole",
"Description": "Grant the Subscribers role",
"Parameters": {
"RoleId": {
"Expression": "",
"Value": "2",
"IsExpression": false,
"Parameters": {}
},
"RoleNames": "",
"DateSelectionMode": {
"Expression": "",
"Value": "OffsetFromNow",
"IsExpression": false,
"Parameters": {}
},
"ExtensionDays": "",
"StartDate": {
"Date": ""
},
"StartDateToken": "",
"ExpireDate": {
"Date": ""
},
"ExpireDateToken": "",
"RoleExpiration": ""
}
}
Revised 09/26/2026