Triggering Update Event¶
To trigger an event, update an existing Order
object in the Backendless database. This can be done with any Backendless SDK (Android, iOS, JS, .NET), REST API or Backendless Console:
HashMap<String, Object> orderObject = // retrieve an existing object
// update a property in the object
orderObject.put( "orderAmount", 1200 );
// now save the updated object
Backendless.Data.of( "Order" ).save( orderObject, new AsyncCallback<Map>()
{
@Override
public void handleResponse( Map updatedOrder )
{
Log.i( "MYAPP", "Object has been updated in the database - " + updatedOrder.get( "objectId" ) );
}
@Override
public void handleFault( BackendlessFault fault )
{
Log.e( "Server reported an error " + fault.getDetail() );
}
} );
Order class:
package com.company;
public class Order
{
public String objectId;
public String orderName;
public Double orderAmount;
}
Order order = // retrieve an order from the database
// update an order property
order.orderAmount = 2150d;
// save the object in the database
Backendless.Data.of( Order.class ).save( order, new AsyncCallback<Order>()
{
@Override
public void handleResponse( Order updatedOrder )
{
Log.i( "MYAPP", "Order object has been updated in the database - " + updatedOrder.objectId );
}
@Override
public void handleFault( BackendlessFault fault )
{
Log.e( "Server reported an error - " + fault.getDetail() );
}
} );