-
Notifications
You must be signed in to change notification settings - Fork 26
MobileCRM.UI.LookupForm.showAsync
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.
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.
// WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
// It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
function chooseParentCustomer() {
return __awaiter(this, void 0, void 0, function* () {
try {
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
var accountRef = yield lookupForm.showAsync();
// 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);
}
catch (err) {
MobileCRM.bridge.alert(err);
}
});
}