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.5K All Categories
 - 88 General
 - 13 Training
 - 214 Installation / Setup
 - 1.2K Flows
 - 112 Rules
 - 277 Administration
 - 215 Portal
 - 503 General Q & A
 - 722 Forms
 - 356 Reports
 - 3 Designer Extensions
 - 47 Example Flows
 - 58 CSS Examples
 - 1 Diagram Tile
 - 8 Javascript Controls
 - 190 Pages
 - 5 Process Mining
 - New Features
 - 187 Datastructures
 - 73 Repository
 - 238 Integrations
 - 30 Multi-Tenant
 - 27 SDK
 - 81 Modules
 - 60 Settings
 - 27 Active Directory
 - 12 Version 7
 - 37 Version 8
 - 143 Lunch And Learn Questions