Xrm.Utility.openEntityForm的使用

通常需要直接打开某一个form,并且有时需要在打开时直接设置默认值。
SDK中直接给提供了下面这个方法: Xrm.Utility.openEntityForm
这里写图片描述
结合我个人的实际例子再进行说明:

OpenOrder = function () {

    var parameters = {};
    // 为查找类型字段赋值
    parameters["new_servicerequset"] = Xrm.Page.data.entity.getId();
    parameters["new_servicerequsetname"] = Xrm.Page.getAttribute("new_requestname").getValue();

    // 为文本类型字段进行赋值
    parameters["new_workordername"] = Xrm.Page.getAttribute("new_requestname").getValue();

    // 为日期类型字段进行赋值  
    parameters["new_receiving_date"] = "2015-11-15 16:00:00.000";
    // 或者
    parameters["new_receiving_date"] = Xrm.Page.getAttribute("new_expected_date").getValue().toDateString();

    // 为选项集类型字段进行赋值     
    parameters["new_type"] = Xrm.Page.getAttribute("new_type").getValue();

    // 打开实体Form
    Xrm.Utility.openEntityForm("new_serviceworkorder", null, parameters);
}

Note:
因为最后会拼接成url字符串,所以赋值时不能直接赋值为object.必须转化为字符串。
例如对日期类型的赋值。

在调用这个方法时通常会出现下面这个错误。

这里写图片描述

觉得很奇怪,调查之后发现在我们调用 Xrm.Utility.openEntityForm(“new_serviceworkorder”, null, parameters);方法时,最后会把我们传递的参数都拼接成URL字符串,而通常浏览器会对URL的长度有最大限制。

解决方案可以参考下面这个链接:
http://www.cnblogs.com/luchaocai/p/3182510.html
这里写图片描述

微软官方给出的方案如下:

RESOLUTION
To resolve this problem, follow these steps:
Click Start, type Notepad in the Start Search box, right-click Notepad, and then click Run as administrator.

Note If you are prompted for an administrator password or for a confirmation, type the password, or click Continue.

On the File menu, click Open, type %windir%\System32\inetsrv\config\applicationHost.config in the File name box, and then click Open.
In the ApplicationHost.config file, locate the requestLimits tag.
Remove the maxQueryString property. Or, change the value to a value that matches the length of the query string that you are using. By default, the value of the maxQueryString property is 2048.

For example, modify the following code.

Save the ApplicationHost.config file.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值