Skip to content

MobileCRM.UI._DetailView.insertItem

rescocrm edited this page May 15, 2023 · 9 revisions

[v8.0] Inserts the MobileCRM.UI.DetailViewItems.Item into this detailed view.

Arguments

Argument Type Description
item MobileCRM.UI.DetailViewItems.Item An item to be added.
index Number An index on which the item should be placed. Set to -1 to append the item at the end.

This example demonstrates how to insert the link/check box items on existing detail view tab, how to handle the changes and how to bind the click handler for link item.

MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
	var detailView = entityForm.getDetailView("General");
	var linkItem = detailView.getItemByName("SaveLink");
	if (linkItem) {
		// The item was already inserted on the form.
		// Just set the value property and bind the handler.
		linkItem.setTypedValue("value", "System.String", "Save"); // The type must be set explicitly for LinkItem
		detailView.registerClickHandler(linkItem, onLinkItemClick);
	}
	else {
		// create MobileCRM.UI.DetailViewItems.LinkItem
		linkItem = new MobileCRM.UI.DetailViewItems.LinkItem("SaveLink", "Save");
		detailView.registerClickHandler(linkItem, onLinkItemClick);
		detailView.insertItem(linkItem, -1); // Place the item as the last one.
	}
	var checkBoxItem = detailView.getItemByName("ShowDetails");
	if (checkBoxItem) {
		// The item was already inserted on the form.
		// Just set the value property.
		checkBoxItem.value = true;
	}
	else {
		// create MobileCRM.UI.DetailViewItems.CheckBoxItem
		checkBoxItem = new MobileCRM.UI.DetailViewItems.CheckBoxItem("ShowDetails", "Show Details");
		checkBoxItem.value = true;
		detailView.insertItem(checkBoxItem, 0); // Place the item as the first one.
	}
}, MobileCRM.bridge.alert, null);
function onLinkItemClick(itemName, detailViewName) {
	MobileCRM.UI.EntityForm.saveAndClose();
}
MobileCRM.UI.EntityForm.onChange(function (entityForm) {
	if (entityForm.context.changedItem == "ShowDetails") {
		var detailView = entityForm.getDetailView("General");
		var checkBoxItem = detailView.getItemByName("ShowDetails");
		if (checkBoxItem.value) {
			// Show your details
		}
		else {
			// Hide your details.
		}
	}
}, MobileCRM.bridge.alert, null);
Clone this wiki locally