-
Notifications
You must be signed in to change notification settings - Fork 26
MobileCRM.UI.LookupForm.show
rescocrm edited this page May 15, 2023
·
9 revisions
Shows a dialog which allows the user to select an entity from a configurable list of entity types.
Argument | Type | Description |
---|---|---|
success | function(obj) | The callback function that is called with chosen MobileCRM.Reference object. |
failed | function(errorMsg) | The errorCallback which is called asynchronously in case of error. |
scope | Object | The scope for callbacks. |
This example demonstrates how to choose the parent customer from Contact form. This code opens up the Account list and sets chosen Account into the parent customer field of the currently edited Contact.
function chooseParentCustomer() {
var lookupForm = new MobileCRM.UI.LookupForm();
// HOW TO ADD ADDITIONAL FILTERING TO LOOKUP FORM.
var customXMLView = '<fetch version="1.0"><entity name="account">' +
'<filter type="and"><condition attribute="address1_city" operator="like" value="Bratislava"/></filter></entity></fetch>';
lookupForm.addEntityFilter("account", customXMLView);
lookupForm.addView("account", "Default");
lookupForm.allowNull = true; // Allow choosing empty value
lookupForm.show(onLookupFinished, MobileCRM.bridge.alert, null);
}
function onLookupFinished(accountRef) {
/// <param name="accountRef" type="MobileCRM.Reference"/>
// Change the parent customer on currently edited contact entity
MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
/// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
var editedContact = entityForm.entity;
var newCustomer = accountRef ? new MobileCRM.Reference(accountRef.entityName, accountRef.id, accountRef.primaryName) : null;
editedContact.properties["parentcustomerid"] = newCustomer;
}, MobileCRM.bridge.alert);
}