Backendless Support
 

Dynamic user definition with the Registration API

When an app user is registered with the API in Backendless, by default a Backendless backend declares a user entity with three properties: email, password and name. The "email" property is configured as identity by default, meaning its value should be passed into the login API request.

Typically user entity properties correspond to the fields in the app's user registration form. When a user registers with the app, the data from the registration form is sent to the server using the User Registration API. While processing a user registration request, Backendless extracts information from the incoming user object and if it contains a new (undeclared on the backend) property, the property is added to the user entity schema. Consider the following sample code:

                                FOR Objective-C and Swift implementations CLICK HERE

JAVA

Synchronous API (Plain Java):

Calendar calendar = Calendar.getInstance();
calendar.set(1980, 5, 12 );
Date birthDate = calendar.getTime();
BackendlessUser user = new BackendlessUser();
user.setEmail( "spiderman@backendless.com" );
user.setPassword( "greeng0blin" );
user.setProperty( "name", "Spidey" );
user.setProperty( "birthdate", birthDate );
user.setProperty( "employeeId", 101 );
Backendless.UserService.register( user );
Asynchronous API (Android and Plain Java):
Calendar calendar = Calendar.getInstance();
calendar.set( 1980, 5, 12 );
Date birthDate = calendar.getTime();
BackendlessUser user = new BackendlessUser();
user.setEmail( "spiderman@backendless.com" );
user.setPassword( "greeng0blin" );
user.setProperty( "name", "Spidey" );
user.setProperty( "birthdate", birthDate );
user.setProperty( "employeeId", 101 );
Backendless.UserService.register( user, new AsyncCallback<BackendlessUser>()
{
 @Override
 public void handleResponse( BackendlessUser backendlessUser )
 {
 System.out.println( "user has been registered" );
 }
 @Override
 public void handleFault( BackendlessFault backendlessFault )
 {
 System.out.println( "server reported an error - " + backendlessFault.getMessage() );
 }
} );

Once a developer runs the code Backendless creates the "birthdate" and "employeeId" properties. 

It can be verified in Backendless console:

  1. Login to Backendless, select your app and click the Users icon.
  2. The User Properties screen displays the user entity definition:
  3. The registered user also appears in the Users table available in the Data screen: 

The behavior of declaring user entity properties dynamically can be turned off by using the Enable Dynamic User Definition toggle. The toggle is located on the Users > User Properties screen: 

Review related topics:

Is article helpful?