Lookup 字段的 DataValue 始终为空
我在 IE8 中使用 MS CRM 4。
在“订单产品”表单上,我尝试使用“数量”字段的 OnChanged 事件,根据“产品查找”字段的当前值向用户提供一些反馈。
我的问题是,无论我做什么,该字段的 DataValue 属性始终为空。
这是我正在测试的 javascript:
if (crmForm.all.productid_d.DataValue == null)
alert('DataValue is null');
else
{
alert ('DataValue is non-null');
alert('Length: ' + crmForm.all.productid_d.DataValue.Length);
}
请注意,我已检查 crmForm.all.productid_d 绝对非空,并且它包含我感兴趣的值。从 IE8 开发人员窗口:
<td id="productid_id">
<table width="100%" class="ms-crm-Lookup" style="table-layout: fixed;" cellSpacing="0" cellPadding="0">
<tbody>
<tr>
<td>
<div tabIndex="1011" class="ms-crm-Lookup " style="width: 100%;" ime-mode="auto">
<span class="ms-crm-Lookup-Item" contentEditable="false" onclick="openlui()" otypename="product" otype="1024" oid="{DA770EAE-A4FB-DD11-BBD6-001A646872CF}" data="" ?="">
<img class="ms-crm-Lookup-Item" alt="" src="/_imgs/ico_16_1024.gif" complete="complete" imageSrc="/_imgs/ico_16_1024.gif"/>
Text - Travel Expenses
<a tabIndex="-1" title="Travel Expenses" class="atLink" id="at{DA770EAE-A4FB-DD11-BBD6-001A646872CF}" contentEditable="false" onclick="return false;" href="javascript:onclick();" target="_self"/>
<b class="IMG_lu_htc_b"/>
在上面的代码中,我有兴趣从查找字段中读出“旅行费用”条目。
然而,即使 Lookup 字段中肯定加载了一个值,Datavalue 仍然返回 null。
根据我能找到的示例,我的 JavaScript 看起来很正确,并且我已确认 crmForm.all.product_d 存在且不为空。
对正在发生的事情有什么想法吗?
I'm using MS CRM 4 in IE8.
On the Order Product form, I am attempting to use the OnChanged event of the Quantity field do give some feedback to the user based on the current value of the Product lookup field.
My problem is that no matter what I do, the DataValue property of the field is always null.
Here's the javascript I'm testing with:
if (crmForm.all.productid_d.DataValue == null)
alert('DataValue is null');
else
{
alert ('DataValue is non-null');
alert('Length: ' + crmForm.all.productid_d.DataValue.Length);
}
Note that I've checked that crmForm.all.productid_d is definitely non-null, and that it contains the values I'm interested. From the IE8 developer window:
<td id="productid_id">
<table width="100%" class="ms-crm-Lookup" style="table-layout: fixed;" cellSpacing="0" cellPadding="0">
<tbody>
<tr>
<td>
<div tabIndex="1011" class="ms-crm-Lookup " style="width: 100%;" ime-mode="auto">
<span class="ms-crm-Lookup-Item" contentEditable="false" onclick="openlui()" otypename="product" otype="1024" oid="{DA770EAE-A4FB-DD11-BBD6-001A646872CF}" data="" ?="">
<img class="ms-crm-Lookup-Item" alt="" src="/_imgs/ico_16_1024.gif" complete="complete" imageSrc="/_imgs/ico_16_1024.gif"/>
Text - Travel Expenses
<a tabIndex="-1" title="Travel Expenses" class="atLink" id="at{DA770EAE-A4FB-DD11-BBD6-001A646872CF}" contentEditable="false" onclick="return false;" href="javascript:onclick();" target="_self"/>
<b class="IMG_lu_htc_b"/>
In the code above, it is the 'Travel Expenses' entry that I'm interested in reading out from the Lookup field.
However - even though there is definitely a value loaded in the Lookup field, the Datavalue still returns null.
My JavaScript looks right to me based on the examples I can find, and I've comfirmed that crmForm.all.product_d exists and is not null.
Any thoughts regarding what's going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要 crmForm.all.productid 而不是 crmForm.all.productid_d。在实际的 HTML 中,会有一个名为 Productid_d 的字段,即使它可能具有您想要的值,但如果您从 crmForm.all 集合访问它,只需使用属性名称即可。
You want crmForm.all.productid and not crmForm.all.productid_d. In the actual HTML, there will be a field called productid_d, and even though it may have the value you want, if you access it from the crmForm.all collection, just use the attribute name.