web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Subgrid filter using javascript in dynamic crm

(0) ShareShare
ReportReport
Posted on by 256

I have one custom entity. On custom entity, I have quote details subgrid. in subgrid, we are showing few fields from quote details and few from quote. 

I have one text field on custom entity: quote id. I am filtering subgrid based on quote id. filter is working fine for me. But when subgrid is filtered then that is showing only quote details fields data not quote data. 

For example: my subgrid view have product name and unit from quote details and account id and quote id from quote. I am.getting data in product name but not in account id and quote id.

If anyone faced same issue please help.IMG_5F00_20200506_5F00_164957_5F005F00_01.jpg

I have the same question (0)
  • RHOU Profile Picture
    65 on at
    RE: Subgrid filter using javascript in dynamic crm

    I just created a very detailed feature wish

    PLEASE VOTE!

    powerusers.microsoft.com/.../675538

  • Johao Larios Profile Picture
    1,795 on at
    RE: Subgrid filter using javascript in dynamic crm

    Hello Ankit,

    Thanks for sharing your code.

    Over here I see a couple of things that you should check.

    First, we don't support modify DOM elements through JS:  docs.microsoft.com/.../customizations-supported

    Secondly, you should be using the gridContext to interact with the grid:  docs.microsoft.com/.../grids

    at third place, we also recommend use the formContext to interact with fields on the form:  docs.microsoft.com/.../execution-context

    So, I think first you should get familiar with these guys and then start playing with the subgrid using the recommended ways.

    Please let me know if you have any questions so far.

    Regards

  • AnkitSinghal Profile Picture
    256 on at
    RE: Subgrid filter using javascript in dynamic crm

    Below is my code :

    function filterQuoteGridForAccountid2()

    {

    //Get Subgrid control

    var quoteSubGrid = window.parent.document.getElementById("CustomOrderRequestGrid2");

       if (quoteSubGrid == null) {// || quoteSubGrid1.readyState != "complete"

           setTimeout(filterQuoteGridForAccountid2, 2000);

           return;

       }

       else {

           var accountID2= null;

           if (Xrm.Page.getAttribute("dsl_searchaccountlookup").getValue() != null)

           {

           accountID2 = Xrm.Page.getAttribute("dsl_searchaccountlookup").getValue()[0].id.replace("}", "").replace("{", "");

           var fetchXml = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">'

           +'<entity name="quotedetail">'

           +'<attribute name="productid" />'

           +'<attribute name="quotedetailid" />'

           +'<attribute name="dsl_accountsid" />'

           +'<order attribute="productid" descending="false" />'

           +'<link-entity name="account" from="accountid" to="dsl_accountsid" visible="false" link-type="outer" alias="adc">'

           +'<attribute name="dsl_accountid" />'

           +'</link-entity>'

           +'<link-entity name="quote" from="quoteid" to="quoteid" visible="false" link-type="inner" alias="ad">'

           +'<attribute name="dsl_contact" />'

           +'<attribute name="dsl_accountid" />'

           +'<attribute name="dsl_companyid" />'

           +'<attribute name="customerid" />'

           +'<filter type="and">'

           +'<condition attribute="dsl_accountid" operator="eq" uitype="account" value="' + accountID2 + '" />'

           +'</filter>'

           +'</link-entity>'

           +'</entity>'

           +'</fetch>';

    if(quoteSubGrid.control != null)

        {

           quoteSubGrid.control.SetParameter("fetchXml", fetchXml);

           //Refresh grid to show filtered records only.

           quoteSubGrid.control.Refresh();

        }

        else

        {

           setTimeout(filterQuoteGridForAccountid2, 2000);

        }

    }

    }

    }

  • Johao Larios Profile Picture
    1,795 on at
    RE: Subgrid filter using javascript in dynamic crm

    Ankit,

    Share your code over here so we can take a look on it.

  • AnkitSinghal Profile Picture
    256 on at
    RE: Subgrid filter using javascript in dynamic crm

    hi johao..

    I am getting that for that field from the fetch XML but after bind the data to the subgrid that field does not show any value.

  • Johao Larios Profile Picture
    1,795 on at
    RE: Subgrid filter using javascript in dynamic crm

    Hello Ankit,

    Have you debugged this?

    By debugging you can tell what data is being passed to the row, so you can check if you are sending the correct data to the grid or not, if the data is not being passed to the row, so you will need to add it to the row object as needed.

    regards

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 258

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 179

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 127 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans