MobileCRM.UI.RoutePlan.onItemSave - Resconet/JSBridge GitHub Wiki
Binds or unbinds the handler for validating single visit entity save.
Bound handler is called with the RoutePlan object as an argument.
The RoutePlan context object contains property "errorMessage" that can be used to cancel save with an error and property "entityToSave" carrying visit DynamicEntity record.
Use suspendSave method to suspend the save process if an asynchronous operation is required.
Argument | Type | Description |
---|---|---|
handler | function(RoutePlan) | 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 perform asynchronous route entitiy save validation when saving visit from the route details.
var handler = routePlan.suspendSave();
MobileCRM.UI.RoutePlan.onItemSave(function (routePlan) {
var entityToSave = routePlan.context.entityToSave;
// Perform additional asynchronous validation on entities that are about to be saved.
checkParentAccountAsync(entityToSave, function (errorMessage) {
if (errorMessage)
handler.resumeSave("Can't save the route: " + errorMessage);
else
handler.resumeSave();
});
});