Skip to content

Find User By

Description

This operation finds a specific user by objectId or by identity in the Users data table. The search by identity is only available in Codeless.

Method

Blocking API:

BackendlessUser Backendless.UserService.Data.Of<BackendlessUser>().FindById(String objectId);

Non-blocking API:

Task<BackendlessUser> Backendless.UserService.Data.Of<BackendlessUser>().FindByIdAsync(String objectId);

Non-blocking API with Callback:

void Backendless.UserService.Data.Of<BackendlessUser>().FindById(String objectId, AsyncCallback<BackendlessUser> callback);

where:

Argument                Description
objectId Unique identifier of a user record to retrieve from the data table. String value or number. Refer to the Data Import topic to learn more about objectId value as the number.
callback A callback object which will receive a callback when the method successfully returns a result or an error. Applies to the non-blocking methods only.

Return Value

The BackendlessUser object containing user data.

Example

The example below obtains the user object associated with the following objectId: "4D584E4D-05A3-4AC4-90C7-B80D1584E7AD"

Blocking API:

BackendlessUser user = Backendless.Data.Of<BackendlessUser>().FindById("4D584E4D-05A3-4AC4-90C7-B80D1584E7AD");
Backendless.UserService.CurrentUser = user;

Non-blocking API:

BackendlessUser user1 = await Backendless.Data.Of<BackendlessUser>().FindByIdAsync("4D584E4D-05A3-4AC4-90C7-B80D1584E7AD");
Backendless.UserService.CurrentUser = user;

Non-blocking API with Callback:

Backendless.Data.Of<BackendlessUser>().FindById("4D584E4D-05A3-4AC4-90C7-B80D1584E7AD", new AsyncCallback<BackendlessUser>(
  user =>
  {
    Backendless.UserService.CurrentUser = user;
  },
  fault =>
  {
    // Server returned an error
  }));

Codeless Reference

user_service_codeless_find_user_by

where:

Argument                Description
objectId Unique identifier of the user object which is used to obtain the user data from the Users data table.
identity A value for a column in the Users table marked as identity. By default the column marked as identity isemail, however, it can be changed to another column in Backendless Console.

Returns the BackendlessUser object containing user data. The object has the values for all the properties stored in Users data table.

Consider the following record in the Users data table:
user_service_codeless_example_remove_user_3

The example below finds the user by "alice@yourmail.com" identity and returns the BackendlessUser object containing user data.

user_service_codeless_example_find_user_by_2

The output will look as shown below after the Codeless logic runs:

user_service_codeless_example_find_user_by_4

The example below finds the user by objectId: "4D584E4D-05A3-4AC4-90C7-B80D1584E7AD" and returns the BackendlessUser object containing user data.

user_service_codeless_example_find_user_by_1

The output will look as shown below after the Codeless logic runs:

user_service_codeless_example_find_user_by_3