-
Notifications
You must be signed in to change notification settings - Fork 26
MobileCRM.DynamicEntity.save
rescocrm edited this page May 15, 2023
·
9 revisions
Performs the asynchronous CRM create/modify entity command.
Argument | Type | Description |
---|---|---|
callback | function(err) | A callback function for asynchronous result. The err argument will carry the error message or null in case of success. The callback is called in scope of DynamicEntity object which is being saved. |
forceMode | Boolean | [v10.0.2] 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 tobe saved in currently selected application offline/online mode. |
This example demonstrates how to create a new account.
var account = MobileCRM.DynamicEntity.createNew("account");
var props = account.properties;
props.name = "A Bike Store";
props.address1_line1 = "Unknown";
// ...
account.save(function (error) {
if (error)
MobileCRM.bridge.alert("An error occurred: " + error);
else {
// callback is called in scope of newly created MobileCRM.DynamicEntity object; thus we can access the data using "this" keyword
var newId = this.id;
var allProps = this.properties;
rememberNewAccount(newId, allProps.name);
}
});
This example demonstrates how to modify an existing account. It updates the GPS coordinates for given account.
function updateGPS(accountid, latitude, longitude) {
var account = new MobileCRM.DynamicEntity("account", accountid);
var props = account.properties;
props.address1_latitude = latitude;
props.address1_longitude = longitude;
account.save(function (error) {
if (error)
MobileCRM.bridge.alert("An error occurred: " + error);
else {
// callback is called in scope of newly created MobileCRM.DynamicEntity object; thus we can access the data using "this" keyword
logModification(this.id, this.primaryName);
}
});
}