简体   繁体   English

使用Javascript创建自定义查找

[英]Creating a custom lookup with Javascript

This code worked in 4.0, in 2011 when I try to set the value of the lookup I get an error with 'initializelookuppresence' 该代码在4.0中有效,2011年,当我尝试设置查找的值时,出现“ initializelookuppresence”错误

4.0 Code 4.0代码

lookupCell.innerHTML = '<TABLE style="table-layout: fixed" class="ms-crm-Lookup" cellspacing="0" cellpadding="0" width="100%"><TBODY><TR><TD><DIV class="ms-crm-Lookup" tabindex="1011" role="list" ime-mode="auto" ms-crm-hidden-nobehavior><UL style="float: left"></UL></DIV><LABEL class="ms-crm-Hidden-NoBehavior" for=' + id + '_ledit>Related Entity</LABEL><INPUT style="display: inline"  id='+ id +'_ledit class=ms-crm-Hidden-NoBehavior disabled tabIndex=1010 ime-mode="auto"></TD><TD class=Lookup_RenderButton_td width=25><IMG style="ime-mode: auto" id=' + id + ' class="ms-crm-Lookup ms-crm-ImageStrip-btn_off_lookup" title="Click to select a value for Company." alt="Click to select a value for Company." src="/_imgs/imagestrips/transparent_spacer.gif" savedquerytype="" forfield=' + label + ' isDisplayOnly="False"  resolveemailaddress="0" disableviewpicker="0" disablequickfind="0" disablemru="0" allowfilteroff="1" AutoResolve="1" additionalparams=""  defaulttype="2" lookupstyle="single" lookupbrowse="0" lookuptypeIcons="/_imgs/ico_16_2.gif:/_imgs/ico_16_8.gif" lookuptypenames="contact:2:Contact,systemuser:8:User" lookuptypes="2,8" attrpriv="7"  req="1" _lookupstyle="single" _lookuptypes="2,8" _lookupbrowse="0"><A title="Click to select a value for Company." tabIndex=-1 onclick=previousSibling.click(); href="#"></A></TD></TR></TBODY></TABLE>';

Has anyone tried this successfully in 2011? 有人在2011年成功尝试过吗?

You are replacing the lookup control completely. 您将完全替换查找控件。 It is not rendered with the same HTML in 2011 as it was in 4.0. 在2011年,它使用的HTML与4.0中的HTML不同。 Any messing with these control's HTML is unsupported. 不支持任何与这些控件的HTML混淆的事情。 However, I see some overriding of the entity lookup types there... and Im guessing that is all you are looking to achieve, correct? 但是,我在那里看到了一些实体查找类型的重载...而且我想这就是您想要实现的所有内容,对吗? The (also unsupported) way of achieving this is to override the element's attributes (rather than the entire control). 实现此功能的(也是不受支持的)方法是覆盖元素的属性(而不是整个控件)。

document.getElementById("parentcustomerid").setAttribute("lookuptypes","2"); document.getElementById(“ parentcustomerid”)。setAttribute(“ lookuptypes”,“ 2”);
document.getElementById("parentcustomerid").setAttribute("lookuptypenames", "contact:2"); document.getElementById(“ parentcustomerid”)。setAttribute(“ lookuptypenames”,“ contact:2”); document.getElementById("parentcustomerid").setAttribute("lookuptypeIcons", "/_imgs/ico_16_2.gif"); document.getElementById(“ parentcustomerid”)。setAttribute(“ lookuptypeIcons”,“ /_imgs/ico_16_2.gif”); document.getElementById("parentcustomerid").setAttribute("defaulttype", "2"); document.getElementById(“ parentcustomerid”)。setAttribute(“ defaulttype”,“ 2”);

I found the comments in Rhett's post here quite useful for more details on that. 我发现Rhett在这里的帖子中的评论对于此方面的更多细节非常有用。

Hope that helps. 希望能有所帮助。

我认为您需要以下

Xrm.Page.getAttribute(“fieldName”).setValue([new {id: idValue, name: textValue, entityType: typeValue}]);

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

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