Dynamics CRM - 通过 JavaScript 使用 Fetch XML 对 Sub-grid 结果进行筛选过滤

一、如何指定 Partylist 类型字段能 lookup 的实体(以 Appointment 中某个字段为例子):

      代码如下:

var control = Xrm.Page.getControl("requiredattendees");
control.getAttribute().setLookupTypes(["systemuser", "contact"]);

 

      执行前:

 

 

      执行后:

 

 

二、使用 JavaScript 对 sub-grid 进行过滤,具体过程如下:

      1.首先打开 CRM 系统的 Advanced Find:

 

      2.选择 Sub grid 对应的 Entity(以 Appointment 为例子),并添加所需要的筛选条件,点击下载 Fetch XML:

 

      3.下载后得到的文本内容如下(有所省略,只是一个sample):

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="appointment">
    <attribute name="..." />
    <attribute name="..." />
    ...
    <attribute name="..." />
    <order attribute="..." descending="true" />
    <filter type="and">
      <condition attribute="actualend" operator="on-or-after" value="2019-04-16" />
    </filter>
  </entity>
</fetch>

 

      4.在 JavaScript 中调用 XML 对 Sub grid 进行过滤:

var sSubGridName = "..." //Sub grid的名字
var caseXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + 
"<entity name='appointment'>" + 
"<attribute name='...' />" + 
"..." + 
"<attribute name='...' />" +
"<order attribute='...' descending='true' />" + 
"<filter type='and'>" +
"<condition attribute='actualend' operator='on-or-after' value='2019-04-16' />" +
"</filter>" +
"</entity>" +
"</fetch>";
var SubGridDetails = window.parent.document.getElementById(sSubGridName);
if (SubGridDetails != null) {
    if (SubGridDetails.control != null) {
        SubGridDetails.control.SetParameter("fetchXml", caseXml); //set the fetch xml to the sub grid   
        SubGridDetails.control.refresh(); //refresh the sub grid using the new fetch xml
    }
}

 

转载于:https://www.cnblogs.com/Sunny20181123/p/10718044.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值