Getting user data in a quick way

Hello everyone,

sorry for what probably is a dumb question, but how do i get user data for current user? (e.g. e-mail, name, etc.)
there is:

public BackendlessUser Backendless.UserService.CurrentUser();

But i can’t find anywhere in the documentation, how to use BackendlessUser (or am i looking the other way?).

Regards,
Anatoliy

Hi Anatoliy,

When you use the login API, the server returns the BackendlessUser object. It should have all the properties except for password. Alternatively, you can use the API you referenced (Backendless.UserService.CurrentUser()). The BackendlessUser class provides the “getProperty” method which would give you the value of the property you need.

Regards,
Mark

Hi Anatoliy,
And there are several samples:

BackendlessUser currentUser = Backendless.UserService.CurrentUser();

can get, for example, email value:

         currentUser.getEmail();

or some custom property:

        currentUser.getProperty( "propertyName" );

Regards,
Kate.

Many thanks for insanely quick reply!!!

I Was wondering on what is the fastest/best way to retrieve all properties on a set of users.

For example, I have a table called “Groups” which has a list of users in a data relation table, and i want to not only retrieve al the users, but their properties (Phone number, email, location, etc.).
Right now I just call “.getProperties()” on every single user, but can i call the server once and get all the same information? Thanks.

When you call .getProperties() there are no server calls here. All data is already retrieved when you call Backendless.Data.find()