0
votes

I am trying to provide a quick filter option for Microsoft Dynamics CRM users that allows them to quickly sub-filter a homepage view.

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. It uses their input to create fetch XML and then passes that back to the grid on the main page. This worked prior to the UCI, but no longer works with the UCI. The code in my HTML web resource doesn't seem to be able to "find" the control or push the XML onto it.

My previous HTML resource relied on something similar to the following script to build the XML and push it to the account homepage:


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();
1
Was my answer helpful?Arun Vinoth - MVP

1 Answers

0
votes

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.

Alternatively - Try to rebuild your requirement in HTML webresource totally, including Grid view and filters/search. Also you can build PCF controls to render the UI natively.