MobileCRM.DynamicEntity.saveAsync - Resconet/JSBridge GitHub Wiki
Performs the asynchronous CRM create/modify entity command.
Arguments
Argument | Type | Description |
---|---|---|
forceMode | Boolean | Optional parameter which forces online/offline mode for saving. Set "true" to save entity online; "false" to save it offline. Any other value (including "undefined") causes entity to be saved in currently selected application offline/online mode. |
This example demonstrates how to modify an existing account. It updates the GPS coordinates for given account.
function updateGPS(accountid, latitude, longitude) {
// Instead of loading whole entity object, we'll create the DynamicEntity object
// for Account entity with existing ID and provide just changed fields.
var account = new MobileCRM.DynamicEntity("account", accountid);
var props = account.properties;
props.address1_latitude = latitude;
props.address1_longitude = longitude;
account
.saveAsync()
.then(function (savedEntity) {
// Promise was fulfilled and we obtained full MobileCRM.DynamicEntity object with all its fields (including primary name)
logModification(savedEntity.id, savedEntity.primaryName);
})
.catch(function (error) {
// Promise was rejected with error
MobileCRM.bridge.alert("An error occurred: " + error);
});
}