我想在账户查询禁用于2016年禁用视图选择器DIV是无法访问在MS CRM
视图选择器的代码工作正常,我的意思是,我没有得到任何错误,但这些代码并没有能够找到“parentaccountid”的特定DIV。
但它返回{NULL}当代码试图获得DIV的元素 - 的document.getElementById(“parentaccountid”);
我的代码的机会页的负荷运行。
即使在这个步骤中,可以看到特定的DIV元素 - ID:parentaccountid
在哪里,因为我仍然得到{}空值:
如在哪里在2013年我看到它工作得很好。 对不起,我没有数据在这里分享,但它工作正常。
这里是下面的代码:
function DisablePick()
{
\t VULoader();
\t
\t //call this function from OnLoad handler
\t function VULoader(){
\t \t var myLookup1;
alert("Hello..I am Here");
\t var fetch = "<fetch mapping='logical'>"
+"<entity name='account'>"
+"<attribute name='name'/>"
+"<filter type='and'>"
+"<condition attribute='name' operator='eq' value='Blue Yonder Airlines (sample)' />"
+"</filter>"
+"</link-entity>"
+"</entity>"
+"</fetch>";
\t \t
\t \t myLookup1 = new XrmLookupField("parentaccountid");
\t \t myLookup1.AddLockedView(
\t \t \t //sViewId
\t \t \t myLookup1.NewGuid() ,
\t \t \t //sEntityName
\t \t \t "account",
\t \t \t //sViewDisplayName
\t \t \t "My Locked Custom View",
\t \t \t //sFilterXml
\t \t \t fetch,
\t \t \t //sFilterLayout
\t \t \t layout(1, "name", "accountid")
\t \t \t \t .column("name", 200)
\t \t \t .toString()
\t \t);
\t }
\t function XrmLookupField(sId) {
\t \t var xlf = this;
\t \t //control instance
\t \t xlf.Ctl = Xrm.Page.getControl(sId);
\t \t //dom instance
\t \t xlf.Dom = document.getElementById(sId);
\t \t //jquery instance
\t \t xlf.$ = $(xlf.Dom);
\t
\t \t /* 2013 addition --- Inline Control instance --- */
\t \t xlf.$i = $("#" + sId + "_i");
\t
\t \t //use that to disable the view picker
\t \t xlf.DisableViewPicker = function() {
\t \t \t /* 2013 addition --- The attribute capitalization changed */
\t \t \t xlf.SetParameter("disableviewpicker", "1");
\t \t }
\t \t //use that to enable the view picker
\t \t xlf.EnableViewPicker = function() {
\t \t \t /* 2013 addition --- The attribute capitalization changed */
\t \t \t xlf.SetParameter("disableviewpicker", "0");
\t \t }
\t \t
\t \t //set undocumented attributes
\t \t \t xlf.SetParameter = function (sName, vValue) {
\t \t \t xlf.$.attr(sName, vValue);
\t
\t \t \t /* 2013 addition --- Also change the inline contorl value */
\t \t \t xlf.$i.attr(sName, vValue);
\t \t }
\t \t
\t \t //add locked view
\t \t xlf.AddLockedView = function (sViewId, sEntityName, sViewDisplayName, sFilterXml, sFilterLayout) {
\t \t \t //first enable the view picker
\t \t \t xlf.EnableViewPicker();
\t \t \t //add the custom view (last parameter set the view as default)
\t \t \t xlf.Ctl.addCustomView(sViewId, sEntityName, sViewDisplayName, sFilterXml, sFilterLayout, true);
\t \t \t //lock the view picker
\t \t \t xlf.DisableViewPicker();
\t \t }
\t \t //create new guid
\t \t xlf.NewGuid = function() {
\t \t \t var d = new Date().getTime();
\t \t \t var guid = '{xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx}'.replace(/[xy]/g, function (c) {
\t \t \t \t var r = (d + Math.random() * 16) % 16 | 0;
\t \t \t \t d = Math.floor(d/16);
\t \t \t \t return (c == 'x' ? r : (r & 0x7 | 0x8)).toString(16);
\t \t \t });
\t \t \t return guid;
\t \t }
\t }
}
几点提:
我呼吁有机会页面加载DisablePicker方法。 是的,我已经检查是否有重复的ID是否存在,但我没有找到任何。
我试图运行此帐户字段负载的方法,但没有响应。
如果我在DIV本身中将属性disableviewpicker值从0更改为1,则在页面加载后手动从浏览器中打开&打开查找,然后它将采用更改的值的效果。
真的,我不明白为什么它的行为如此,我只需要知道我究竟在哪里出错或者它是产品错误,但我不认为它是。作为一个非常基本的行为。
PS:对于我的非MS CRM朋友,我无法更改DIV或除JavaScript代码之外的任何内容。
是的,我可以通过使用parent.document来获得DIV,但我现在有两个问题:看看你是否也可以提供帮助? 1)这是因为CRM 2013页面加载的方式与CRM 2016不同吗? 2)如果是的话,我是否需要在加载时将我的框架设置为ClientApiWrapper.aspx,然后如何或仅仅需要使用Xrm.Page.context.client.getClient代码还是有其他方法。我发现了几个博客,但我没有得到。是的,非常感谢您的意见。 – Deep
1)是的,在某个时候页面结构发生了变化,我不记得具体时间。 2)您发布到CRM中的代码不必担心切换帧,它总是可以执行'parent.document.getElementById'。当您使用开发工具时,您只需关心帧切换。 – Polshgiant