Skip to content

MobileCRM.UI.EntityForm.onChange

rescocrm edited this page May 15, 2023 · 9 revisions

Binds or unbinds the handler for onChange 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 set an "onChange" handler to monitor changes on MobileCRM.UI.EntityForm object. It reacts on changes to "firstname" and "lastname" detail items and sets the "fullname" on edited entity

MobileCRM.UI.EntityForm.onChange(function (entityForm) {
	// First check whether the change handler is called due to desired item change
	var changedItem = entityForm.context.changedItem;
	if (changedItem == "firstname" || changedItem == "lastname") {
		// Get desired DetailView and its items
		var detailView = entityForm.getDetailView("General");
		var firstNameItem = detailView.getItemByName("firstname");
		var lastNameItem = detailView.getItemByName("lastname");
		// Now get edited entity and set its property to the combination of detail items values
		var editedEntity = entityForm.entity;
		editedEntity.properties.fullname = firstNameItem.value + " " + lastNameItem.value;
	}
}, true, null);
Clone this wiki locally