当前位置:网站首页>Dynamics 365 查找字段过滤

Dynamics 365 查找字段过滤

2022-07-07 21:50:00 zcy_wxy

以systemuser为例

addFilterToDisputeControl: function (groupAttrName, ownerAttrName) {
        var viewDisplayName = groupAttrName;
        var lookupControl = Xrm.Page.getControl(ownerAttrName);
        var layoutXml = "<grid name='resultset' object='10013' jump='fullname' select='1' icon='1' preview='1'><row name='result' id='systemuserid'><cell name='fullname' width='300' /><cell name='businessunitid' width='300' /><cell name='scc_leadcount' width='300' /></row></grid>";
        var id = leadForm.guid();
        var entityName = "systemuser";
        var filter = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"
            + "  <entity name='systemuser'>"
            + "<attribute name='systemuserid' />"
            + "<attribute name='fullname' />"
            + "<attribute name='businessunitid' />"
            + "<attribute name='scc_leadcount' />"
            +"    <filter type='and'>"
            +"      <condition attribute='scc_businessgroupid' operator='eq' uitype='scc_businessgroup' value='{0}' />"
            +"    </filter>"
            +"    <link-entity name='systemuserroles' from='systemuserid' to='systemuserid' visible='false' intersect='true'>"
            +"      <link-entity name='role' from='roleid' to='roleid' alias='ab'>"
            +"        <filter type='and'>"
            +"          <condition attribute='name' operator='eq' value='AR' />"
            +"        </filter>"
            +"      </link-entity>"
            +"    </link-entity>"
            +"  </entity>"
            +"</fetch>";
        var group = Xrm.Page.getAttribute(groupAttrName).getValue();
        if (group) {
            filter = filter.replace("{0}", group[0].id);
            lookupControl.addCustomView(id, entityName, viewDisplayName, filter, layoutXml, false);
            lookupControl.setDefaultView(id);
        }
    },
    guid: function(){
        function S4() {
            return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
        }
        return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
    }

注意点:

1、entity中配置的attribute要包含grid中配置的属性名称

2、视图名称最好不同,视图ID则必须不同。

代码中视图ID的生成引用自

https://segmentfault.com/a/1190000041895680

原网站

版权声明
本文为[zcy_wxy]所创,转载请带上原文链接,感谢
https://blog.csdn.net/zcy_wxy/article/details/125639121