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);
            }
        }
 
}



Comments

  1. I just created a very detailed feature wish to make this happen in a supported way for Unified Interface here:

    PLEASE VOTE!

    https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Binding-FetchXML-to-Subgrid-with-reference-to-RecordID-to-filter/idi-p/675538

    ReplyDelete
  2. It is not working linked-entity fetchxml condition..

    ReplyDelete
    Replies
    1. @Vijay
      i didn't tried it with linked-entity fetchxml
      and linked-entity fetchxml didn't works in JS in dynamics

      Delete

Post a Comment

Popular posts from this blog

Connecting to MFA enabled Dynamics 365 V9.X CRM instance through C# or console App