-
Notifications
You must be signed in to change notification settings - Fork 26
MobileCRM.UI.EntityForm.onSave
Maros Kolibas edited this page Nov 28, 2019
·
9 revisions
Argument | Type | Description |
---|---|---|
handler | function(entityForm) | The handler function that has to be bound or unbound. |
bind | Boolean | Determines whether to bind or unbind the handler. |
scope | Object | The scope for handler calls. |
This example demonstrates how to set an "onSave" handler to perform a validation before saving edited value on entity form. It will cancel the validation and sets the error message if the address is incomplete.
MobileCRM.UI.EntityForm.onSave(
function (entityForm) {
var addressDetail = entityForm.getDetailView("Address");
var addrItem = addressDetail.getItemByName("address1_line1");
if (!addrItem.value || addrItem.value.length == 0) {
// Set the error message on detail item
addrItem.errorMessage = "Street 1 line is empty.";
// select second tab (zero-based)
entityForm.form.selectedViewIndex = 1;
entityForm.context.errorMessage = addrItem.errorMessage;
// Return true to apply changed values
return true;
}
// Return false to ignore all changes
return false;
},
true,
null
);