【问题标题】:Jscript to disable view picker on lookup doesn't work in CRM 2013用于在查找时禁用视图选择器的 Jscript 在 CRM 2013 中不起作用
【发布时间】:2014-03-04 15:51:11
【问题描述】:

我正在使用 MS Dynamics CRM 2013,我正面临下一个问题: 在 CRM 2011 中,我使用下一个 jscript 禁用了查找时的视图和实体选择:

document.getElementById("lookup_id").setAttribute("disableViewPicker", "1");
document.getElementById("lookup_id").setAttribute("defaulttype", "1"); 
document.getElementById("lookup_id").setAttribute("lookuptypenames", "account:1:Account");
document.getElementById("lookup_id").setAttribute("lookuptypes", "1");

但在迁移到 Dynamics Crm 2013 后,此脚本不再起作用。

你能帮我解决这个问题吗?谢谢!

【问题讨论】:

    标签: javascript jquery dynamics-crm-2013


    【解决方案1】:

    尝试使用 attributeId 添加“_i”,例如
    contactid 是你的查找属性名称,那么你应该像这样传递

    document.getElementById("contactid_i").setAttribute("disableViewPicker", "1");
    document.getElementById("contactid_i").setAttribute("defaulttype", "1");
    document.getElementById("contactid_i").setAttribute("lookuptypenames","account:1:Account");
    document.getElementById("contactid_i").setAttribute("lookuptypes", "1");
    

    在 crm 2011 中,属性输入 id 与属性名称相同,但在 crm 2013 中,属性输入 id 是属性名称加上“_i”(也许“_i”表示输入)。
    我在掩码和多选择器列表中尝试了这个“_i”,非常适合 2013 年。希望它对您的情况有所帮助。

    https://stackoverflow.com/a/21552357/1915855

    【讨论】:

    • 这适用于“_i”。今天我在升级js到crm 2013的时候测试了一下
    【解决方案2】:

    您也可以在自定义中禁用它, 在表单中,编辑查找时

    在“视图选择器”中选择 -> 关闭

    【讨论】:

      【解决方案3】:

      最佳实践是使用 Xrm.Page 对象:

      Xrm.Page.ui.controls.get("lookup_id").setDisabled(true);
      

      Gareth Tucker 有一个很棒的JavaScript reference for Dynamics CRM

      Dynamics CRM 不支持直接使用 DOM;安装更新汇总后,您当前的代码可能会再次中断。见JavaScript Programming Best Pratices on this MSDN page.

      【讨论】:

      • 我认为您无法使用受支持的方法实现他们想要做的事情。该代码应该是禁用(例如在活动派对中)从帐户或联系人中进行选择的可能性,并强制用户选择,比如说,仅联系人。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 2017-10-25
      • 2015-09-05
      • 2019-04-20
      • 1970-01-01
      • 2018-08-22
      • 2013-12-08
      相关资源
      最近更新 更多