简体   繁体   English

当我有多个元素时,多选Lookup onChange事件不会触发

[英]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. 我正在运行Dynamics CRM 2011 RU 18,并且正在更改JavaScript,以便它将与此新版本兼容。

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 : 添加到onLoad事件的代码

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. 奇怪的是,只有在查找选择了一个元素时,它才进入我的onChange处理程序方法。 When more than on elements are selected it will not enter my onChange handler 当选择了多个on元素时,它将不会进入我的onChange处理程序

The first two lines are directly manipulating the DOM of your CRM form page, bypassing the Xrm.Page API. 前两行绕过Xrm.Page API,直接操作CRM表单页面的DOM。 This is not supported by Microsoft and can lead to unpredictable results. Microsoft不支持此功能,并且可能导致不可预测的结果。

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. CRM中存在的少数多个查找字段都是内置字段。 Unfortunately we cannot add custom ones. 不幸的是,我们无法添加自定义项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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