Hello, I’m working with a where clause to load table objects from the users table.
I can’t seem to figure out how to retrieve the objectId of the current user’s “organization”.
If I copy/paste the objectId from the backend in a text box replacing the get property component it works perfectly. Problem is this needs to retrieve the list of users with the same “organization” as the logged in user.
If it’s in appropriate to do this through the where clause is there a way to achieve the same thing using having clause, relations, or properties?
Thank you
Austin
Hi @Austin_Steil,
try this where clause:
organization.objectId = 'xxxx'
Regards,
Marina
Hi, what are the xxxx intended to be in your example? The current user? If so, that did not work either, returned nothing.
Do I understand correctly that you want to retrieve all users who belong to the same organization as the current user?
Here’s a where clause query to retrieve users of the same organization by knowing objectId of the current (or really any user):
organization.objectId in (organizations[usersAssociated.objectId = 'USER-OBJECT-ID-VALUE'].objectId )
The query takes advantage of the fact that the organizations
table maintains a one-to-many relationship with all the users of the organization.
Regards,
Mark
Thank you so much Mark, it works as intended now.
I have some additional details that might interest you or others because I’m not sure if it’s a bug or if it’s intended to be that way…
When I tried to use the “Get current user” logic block to return the user’s objectId, I was getting nothing. However, I was successful when I created some simple cloud code and used that to return the objectId of the current user.
Thanks again for your help, couldn’t have done it without you.
Austin
Hi Austin,
It looks a bit excessive. I suspect the client side has the user token value, but not the user object. Use the reload
checkbox in the Get current user
block, it should get you the complete user object.
Regards
Mark
1 Like