Filter subgrid in Dynamics unified Hub by Javascript
Hi ,
Recently i came across Problem with Filtering Subgrid by js
I was moving from classic to Unified
In Unified among many JS customizations which are not working
is Subgrid Filter
window.parent.document.getElementById("SubgridName");
Because Dynamics Hub is not supporting It is working fine in Classic but failing in Unified
To make it work in Both UIs here is my code where i filtered data by a lookup
function FilterSubgridBy(id) {
var connectionSubgrid = window.parent.document.getElementById("GridName");
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='account'>" +
" <attribute name='accountid' />" +
" <attribute name='name' />" +
" <attribute name='createdon' />" +
" <attribute name='statecode' />" +
" <order attribute='name' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='new_orderline' operator='eq' uiname='' uitype='salesorder' value='" + id + "' />" +
" </filter>" +
" </entity>" +
"</fetch>"
//Set the fetchxml directly to subgrid
// filter Subgrid in Classic
if (connectionSubgrid) {
connectionSubgrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
connectionSubgrid.control.Refresh(); //refresh the sub grid using the new fetch xml
} else {
//Filter SubGrid in UCI
var connectionSubgridControl = Xrm.Page.getControl("GridName");
if (connectionSubgridControl) {
connectionSubgridControl.setFilterXml(fetchXml); //set the fetch xml to the sub grid
connectionSubgridControl.refresh(); //refresh the sub grid using the new fetch xml
} else {
setTimeout(FilterSubgridBy(id), 1000);
}
}
}
Recently i came across Problem with Filtering Subgrid by js
I was moving from classic to Unified
In Unified among many JS customizations which are not working
is Subgrid Filter
window.parent.document.getElementById("SubgridName");
Because Dynamics Hub is not supporting It is working fine in Classic but failing in Unified
To make it work in Both UIs here is my code where i filtered data by a lookup
function FilterSubgridBy(id) {
var connectionSubgrid = window.parent.document.getElementById("GridName");
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='account'>" +
" <attribute name='accountid' />" +
" <attribute name='name' />" +
" <attribute name='createdon' />" +
" <attribute name='statecode' />" +
" <order attribute='name' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='new_orderline' operator='eq' uiname='' uitype='salesorder' value='" + id + "' />" +
" </filter>" +
" </entity>" +
"</fetch>"
//Set the fetchxml directly to subgrid
// filter Subgrid in Classic
if (connectionSubgrid) {
connectionSubgrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
connectionSubgrid.control.Refresh(); //refresh the sub grid using the new fetch xml
} else {
//Filter SubGrid in UCI
var connectionSubgridControl = Xrm.Page.getControl("GridName");
if (connectionSubgridControl) {
connectionSubgridControl.setFilterXml(fetchXml); //set the fetch xml to the sub grid
connectionSubgridControl.refresh(); //refresh the sub grid using the new fetch xml
} else {
setTimeout(FilterSubgridBy(id), 1000);
}
}
}
I just created a very detailed feature wish to make this happen in a supported way for Unified Interface here:
ReplyDeletePLEASE VOTE!
https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Binding-FetchXML-to-Subgrid-with-reference-to-RecordID-to-filter/idi-p/675538
It is not working linked-entity fetchxml condition..
ReplyDelete..
Delete@Vijay
Deletei didn't tried it with linked-entity fetchxml
and linked-entity fetchxml didn't works in JS in dynamics