[英]Filter Dynamics CRM Account Homepage from HTML with JavaScript in UCI
I am trying to provide a quick filter option for Microsoft Dynamics CRM users that allows them to quickly sub-filter a homepage view.我正在尝试为 Microsoft Dynamics CRM 用户提供一个快速筛选选项,允许他们快速对主页视图进行子筛选。
The customer requirement is to allow an easier experience than what the filters allow, so I added a button that launches an HTML web resource to collect their search criteria.客户要求提供比过滤器允许的更简单的体验,因此我添加了一个按钮来启动 HTML Web 资源以收集他们的搜索条件。 It uses their input to create fetch XML and then passes that back to the grid on the main page.它使用他们的输入来创建获取 XML,然后将其传递回主页上的网格。 This worked prior to the UCI, but no longer works with the UCI.这在 UCI 之前有效,但不再适用于 UCI。 The code in my HTML web resource doesn't seem to be able to "find" the control or push the XML onto it.我的 HTML Web 资源中的代码似乎无法“找到”控件或将 XML 推送到其上。
My previous HTML resource relied on something similar to the following script to build the XML and push it to the account homepage:我之前的 HTML 资源依赖于类似于以下脚本的内容来构建 XML 并将其推送到帐户主页:
var city = "Tampa"; //this input is obtained from the user input in the actual HTML
var fetchType ='<condition attribute="new_orgtype" operator="in"><value>1</value><value>2</value><value>5</value></condition>';
var cityXML = '<condition attribute="address1_city" operator="like" value="'+city+'%"/>';
//concatenate input into a complete fetch XML
var effectiveFetchXml = '<fetch distinct="false" useraworderby="false" no-lock="false" mapping="logical" page="1" count="250" returntotalrecordcount="true"><entity name="account"><attribute name="name" /><attribute name="address1_city" /><attribute name="primarycontactid" /><attribute name="telephone1" /><attribute name="address1_stateorprovince" /><attribute name="parentaccountid" /><attribute name="address1_line1" /><attribute name="websiteurl" /><attribute name="fax" /><attribute name="address1_postalcode" /><attribute name="accountid" /><attribute name="name" /><attribute name="parentaccountid" /><attribute name="primarycontactid" /><attribute name="telephone1" /><attribute name="fax" /><attribute name="websiteurl" /><attribute name="address1_line1" /><attribute name="address1_city" /><attribute name="address1_stateorprovince" /><attribute name="address1_postalcode" /><filter type="and"><condition attribute="statecode" operator="eq" value="0" />'+fetchType+cityXML+'</filter><order attribute="name" descending="false" /></entity></fetch>';
//identify the grid on the main page
var grid = window.opener.document.getElementById("crmGrid");
//Inject the new fetchXml
grid.control.SetParameter("fetchXml", effectiveFetchXml);
grid.control.SetParameter("effectiveFetchXml", effectiveFetchXml);
//Force the subgrid to Refresh
grid.control.Refresh();
This is the reason we must not do any unsupported customizations like this.这就是我们不能进行任何此类不受支持的自定义的原因。 Accessing DOM elements like crmGrid
is not a recommended way - Microsoft always mention that in documentation that it may break in future versions.不推荐访问像crmGrid
这样的 DOM 元素——微软总是在文档中提到它在未来版本中可能会中断。
Alternatively - Try to rebuild your requirement in HTML webresource totally, including Grid view and filters/search.或者 - 尝试在 HTML 网络资源中完全重建您的需求,包括网格视图和过滤器/搜索。 Also you can build PCF controls to render the UI natively.您还可以构建 PCF 控件以本机呈现 UI。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.