Skip to main content
Version: 1.28 (Current)

Load Users from SQL

Audience: Low-code Engineers

Skill 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.

note

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​

Action NameDescription
Load UserLoads specific users and makes the last one the current user.
Send EmailWith Send mail to all users checked, sends one email to each user in the list.
Grant User RoleGrants roles to the current user and to every user in the list.
Revoke User RoleRemoves roles from the current user and from every user in the list.
Authorize UserAuthorizes the current user and every user in the list.
Unauthorize UserUnauthorizes the current user and every user in the list.
Delete UserDeletes the users in the list.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
SQL QueryThe 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]'.Yesempty stringNo

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 NULL values 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 UserPortals in 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​

tip

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