Skip to content

MobileCRM.UI.RoutePlan.onPostSave

rescocrm edited this page May 15, 2023 · 2 revisions

Binds or unbinds the handler for further actions on saved route.

Bound handler is called with the RoutePlan object as an argument.

Use suspendPostSave method to suspend the post-save process if an asynchronous operation is required.

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 saved route contained a new visit ("Sync Login" option has to be turned off and "Save Password" turned on in Woodford configuration).

var syncNeeded = false;
MobileCRM.UI.RoutePlan.onSave(function (routePlan) {
	if (!syncNeeded) {
		// Check if some of route entities isn't new
		syncNeeded = routePlan.myRoute.some(function (e) { return e.isNew; });
	}
}, true);
MobileCRM.UI.RoutePlan.onPostSave(function (routePlan) {
	if (syncNeeded) {
		syncNeeded = false;
		MobileCRM.Application.synchronize(true); // new item was saved - force background sync
	}
}, true);
Clone this wiki locally