Backendless Support
 
Answered

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:

  1. 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

Leave a Comment

Comments (5)

photo
2

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

photo
2

Hi Anatoliy,

And there are several samples:

  1. BackendlessUser currentUser = Backendless.UserService.CurrentUser();

can get, for example, email value:

  1. currentUser.getEmail();

or some custom property:

  1. currentUser.getProperty( "propertyName" );

Regards,

Kate.

photo
1

Many thanks for insanely quick reply!!!

photo
1

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.

photo
1

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

photo