简体   繁体   中英

multi-select Lookup onChange event doesn't fire when I have more than one element

I am running a Dynamics CRM 2011 RU 18, and am changing JavaScript so that it will be compatible with this new version.

I have a multi-select lookup to which I have added an event handler that will save the modification of the value.

code that is added to the onLoad event :

document.getElementById(lookupSchemaName).setAttribute("lookupstyle", "multi");
document.getElementById(lookupSchemaName).setAttribute("_lookupstyle", "multi");

Xrm.Page.getAttribute(lookupSchemaName).addOnChange(function () {Update(...)})

Xrm.Page.getAttribute(lookupSchemaName).setSubmitMode("never");

if (Xrm.Page.ui.getFormType() != CRM_FORM_TYPE_CREATE) {
FillMultiLookup(relationshipSchemaName, lookupSchemaName, relatedEntitySchemaName, relatedEntityPrimaryAttributeSchemaName);
}

else {
    Xrm.Page.getControl(lookupSchemaName).setDisabled(true);
}

The strange thing is that it only enters my onChange handler method when the lookup has one element selected. When more than on elements are selected it will not enter my onChange handler

The first two lines are directly manipulating the DOM of your CRM form page, bypassing the Xrm.Page API. This is not supported by Microsoft and can lead to unpredictable results.

In this specific case you cannot simply change a lookup field meant to hold only one value and expect it to support multiple values. It will simply not work, since it is not accommodated by the corresponding entity relationship.

The few multiple lookup fields existing in CRM are all built-in fields. Unfortunately we cannot add custom ones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM