Skip to content

MobileCRM.UI.RoutePlan.onItemPostSave

rescocrm edited this page May 15, 2023 · 2 revisions

Binds or unbinds the handler for further actions on saved visit entity.

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.

Use suspendSave method to suspend the save process if an asynchronous operation is required and property "savedEntity" carrying saved DynamicEntity object.

Arguments

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 initiate the background synchronization if a new visit was saved from route details ("Sync Login" option has to be turned off and "Save Password" turned on in Woodford configuration).

var itemSyncNeeded = false;
MobileCRM.UI.RoutePlan.onItemSave(function (routePlan) {
	if (!itemSyncNeeded) {
		// Check if entity being saved isn't new
		itemSyncNeeded = routePlan.context.entityToSave.isNew;
	}
}, true);
MobileCRM.UI.RoutePlan.onItemPostSave(function (routePlan) {
	if (itemSyncNeeded) {
		itemSyncNeeded = false;
		MobileCRM.Application.synchronize(true); // new item was saved - force background sync
	}
}, true);
Clone this wiki locally