updateEntity

open suspend fun updateEntity(entity: EntityValue)

See updateEntity_(EntityValue, HttpHeaders?, RequestOptions?).

Parameters

entity

Entity parameter.


open suspend fun updateEntity(entity: EntityValue, headers: HttpHeaders?)

See updateEntity_(EntityValue, HttpHeaders?, RequestOptions?).

Parameters

entity

Entity parameter.

headers

Headers parameter.


open suspend fun updateEntity(entity: EntityValue, headers: HttpHeaders?, options: RequestOptions?)

Update an entity in the target system.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.EntityValue#withDeepUpdate(com.sap.cloud.mobile.kotlin.odata.PropertyPath...) EntityValue.withDeepUpdate}, Update Related Entities When Updating an Entity.

Example using proxy classes:
open fun updateEntityExample(): kotlin.Unit
{
    val service = this.service;
    val query = DataQuery().top(1)
        .filter(Customer.contactName.equal("Jean-Luc Picard"));
    val customer = service.getCustomer(query);
    customer.contactName = "Beverly Crusher";
    service.updateEntity(customer);
}
Example with proxy classes:
open fun deepUpdateExample(): kotlin.Unit
{
    val service = this.service;
    val query = DataQuery().top(1).expand(Customer.orders)
        .filter(Customer.contactName.equal("Beverly Crusher"));
    val customer = service.getCustomer(query);
    val orders = customer.orders;
    val firstOrder = orders[0];
    val nextOrder = orders[1];
    val newOrder = Order();
    newOrder.orderDate = GlobalDateTime.now();
    customer.unbindEntity(firstOrder, Customer.orders);
    nextOrder.requiredDate = GlobalDateTime.now().plusDays(7);
    customer.bindEntity(newOrder, Customer.orders);
    customer.deepUpdateDelta = true;
    service.updateEntity(customer.withDeepUpdate());
}
Example using proxy classes:
open fun updateReplaceExample(): kotlin.Unit
{
    val service = this.service;
    val query = DataQuery().top(1)
        .filter(Customer.contactName.equal("Beverly Crusher"));
    val customer = service.getCustomer(query);
    customer.contactName = "William Riker";
    val options = RequestOptions().update(UpdateMode.REPLACE);
    service.updateEntity(customer, null, options);
}
Example using dynamic API:
open fun updateEntityExample(): kotlin.Unit
{
    val service = this.service;
    val customersEntitySet = service.getEntitySet("Customers");
    val customerEntityType = customersEntitySet.entityType;
    val contactNameProperty = customerEntityType.getProperty("ContactName");
    val query = DataQuery().top(1).from(customersEntitySet)
        .filter(contactNameProperty.equal("Jean-Luc Picard"));
    val customer = service.executeQuery(query).getRequiredEntity();
    contactNameProperty.setString(customer, "Beverly Crusher");
    service.updateEntity(customer);
}

Parameters

entity

Entity to be updated.

headers

(nullable) Optional request-specific headers.

options

(nullable) Optional request-specific options.