SQL Query to get list of accounts a user manages
Comments
-
[font=Roboto, Arial, Helvetica, sans-serif]Im using the following query to get the list of accounts that a user is managing: [/font]
[font=Roboto, Arial, Helvetica, sans-serif]
[/font]
[font=Roboto, Arial, Helvetica, sans-serif]"SELECT concat(concat(ea.first_name, ), ea.last_name) FROM account_relation ar JOIN entity_account ea ON ea.account_id=ar.account_id where ar.entity_name like %Manager% and ar.deleted = False and ar.to_account_id = @account_id;" [/font]
[font=Roboto, Arial, Helvetica, sans-serif]
[/font]
[font=Roboto, Arial, Helvetica, sans-serif]Instead of passing a parameter with account_id is it possible to get current user account id as a subquery so that I can the query looks like this: "SELECT concat(concat(ea.first_name, ), ea.last_name) FROM account_relation ar JOIN entity_account ea ON ea.account_id=ar.account_id where ar.entity_name like %Manager% and ar.deleted = False and ar.to_account_id = (subquery to get account id of current user);"[/font] -
[font=Roboto, Arial, Helvetica, sans-serif]The context of the user running the flow is only available from a Decisions servers memory by mapping in Flow Data > CurrentUserId or Current Account.AccountId. Using a parameterized query to accept that dynamic input is your best option. Other methods to do this would take more server resources and effort to implement than a parameterized query.[/font]
Howdy, Stranger!
Categories
- 4.4K All Categories
- 86 General
- 13 Training
- 212 Installation / Setup
- 1.2K Flows
- 112 Rules
- 282 Administration
- 216 Portal
- 501 General Q & A
- 719 Forms
- 353 Reports
- 3 Designer Extensions
- 48 Example Flows
- 58 CSS Examples
- 1 Diagram Tile
- 8 Javascript Controls
- 189 Pages
- 5 Process Mining
- New Features
- 187 Datastructures
- 71 Repository
- 233 Integrations
- 30 Multi-Tenant
- 27 SDK
- 81 Modules
- 60 Settings
- 27 Active Directory
- 12 Version 7
- 36 Version 8
- 143 Lunch And Learn Questions