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.1K All Categories
- 61 General
- 11 Training
- 201 Installation / Setup
- 1.1K Flows
- 106 Rules
- 260 Administration
- 212 Portal
- 489 General Q & A
- 693 Forms
- 333 Reports
- 3 Designer Extensions
- 47 Example Flows
- 51 CSS Examples
- 1 Diagram Tile
- 7 Javascript Controls
- 178 Pages
- 5 Process Mining
- New Features
- 178 Datastructures
- 69 Repository
- 219 Integrations
- 28 Multi-Tenant
- 27 SDK
- 76 Modules
- 56 Settings
- 25 Active Directory
- 12 Version 7
- 35 Version 8
- 66 Lunch And Learn Questions