admin管理员组文章数量:1302374
I'm trying clear the value of a lookup field via Javascript. I've tried this:
crmForm.all.new_mylookupfield.DataValue = null;
But that isn't working. I inspected the DataValue of the lookup when it was in fact cleared and it returned a null.
alert(document.getElementById("new_mylookupfield").DataValue == null); // true
I'm must be missing something here....
Thanks for the help!
UPDATE: I finally got around to testing some of the suggestions. I'm not sure what I was doing wrong initially, but both of these methods work to clear a lookup via JavaScript:
crmForm.all.new_mylookupfield.DataValue = null;
crmForm.all.new_mylookupfield.DataValue = [];
I'm trying clear the value of a lookup field via Javascript. I've tried this:
crmForm.all.new_mylookupfield.DataValue = null;
But that isn't working. I inspected the DataValue of the lookup when it was in fact cleared and it returned a null.
alert(document.getElementById("new_mylookupfield").DataValue == null); // true
I'm must be missing something here....
Thanks for the help!
UPDATE: I finally got around to testing some of the suggestions. I'm not sure what I was doing wrong initially, but both of these methods work to clear a lookup via JavaScript:
crmForm.all.new_mylookupfield.DataValue = null;
crmForm.all.new_mylookupfield.DataValue = [];
Share
Improve this question
edited Aug 17, 2010 at 4:49
Greg McGuffey
asked May 27, 2010 at 18:40
Greg McGuffeyGreg McGuffey
3,3163 gold badges40 silver badges61 bronze badges
1
- Did you try crmForm.all.new_mylookupfield.DataValue = ""; If you put crmForm.all.new_mylookupfield.DataValue = "HELLO"; what does it do? – xt_20 Commented May 28, 2010 at 1:36
2 Answers
Reset to default 5Lookup controls have a specific type of object for their DataValue. It's an array of objects that look like this:
{
id: /* item id */,
typename: /* entity type name */,
name: /* text to display in link */
}
If you want to remove all values from the lookup, you can set it to null, but it's better to just set it to an empty array.
If you assign the value, but it doesn't seem to change anything, then you are probably not typing the correct id for the attribute. For example: If I have an entity with a lookup attribute of sneakers_brokerid
, then I need to assign that value like so:
crmForm.all.sneakers_brokerid.DataValue = [];
I don't remember having to do this, but have you tried setting the value to just a new Array() with length zero?
本文标签: How to clear Lookup field in MS Dynamics CRM 40 using JavaScriptStack Overflow
版权声明:本文标题:How to clear Lookup field in MS Dynamics CRM 4.0 using JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741668515a2391459.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论