MobileCRM.UI.EntityForm.onPostSave - Resconet/JSBridge GitHub Wiki

[v8.2] Binds or unbinds the handler for onPostSave event on EntityForm.

Arguments

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 use Post Save method while the online mode is running. You are able to create children for parent entity while your parent doesn't exist yet.

MobileCRM.UI.EntityForm.onPostSave(function (entityForm) {
	/// register event.
	var entity = entityForm.entity;
	var account = new MobileCRM.Reference(entity.entityName, entity.id, entity.primaryName);
	var postSuspend = entityForm.suspendPostSave();
	/// create associated contact.
	var contact = new MobileCRM.DynamicEntity.createNew("contact");
	contact.properties.lastname = "_child of " + account.primaryName;
	contact.properties.parentcustomerid = account;
	contact.save(function (err) {
		if (err)
			MobileCRM.bridge.alert(err);
		else {
			postSuspend.resumePostSave();
		}
	});
}, true, MobileCRM.bridge.alert);