Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

Posted on by Microsoft Employee

I tried to use FetchXML through a web resource but it seems like FetchXML is not supported on sub grids in Ms dynamics 2016 update 1. Can someone please guide me in right directions? Thanks

*This post is locked for comments

  • Verified answer
    Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

    Hi Dinesh, I know none of the suggestions in this post answered your question, sorry about that.

    What about a different path?  DId you try looking at PowerBI to really go after the data and create the charts / grids / visualizations you are looking for?  PowerBI will be able to really help you filter in many different ways the information you are trying to capture and will provide great dashboards for your users to "slice and dice" the information.

    Check out the following and I hope it helps Dinesh!

    technet.microsoft.com/.../dn708055.aspx

    Thanks,

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

    Unfortunately, non of the above items worked for me. I do not get errors but grid refreshes and brings the same results. It does not filter by the filter criteria mentioned in fetchXML. Thanks

  • Goutham A Profile Picture
    Goutham A on at
    RE: I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

    The column set should be ths same as the view used. Please see if below thread helps

    https://community.dynamics.com/crm/f/117/t/201756

    http://stackoverflow.com/questions/32564310/dynamics-crm-2015-online-subgrids-control-setparameter-method-is-not-available

  • Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

    To filter by lookupid in FectchXML, use the following code.

    fetchXml += " <condition attribute='parentcustomerid' operator='eq' value='" + lookupid + "' />"

    Hope it helps.

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

    Hi I tried the above step with no luck.. The grid refreshes but the records do not get filtered. No errors thrown in Debug mode. Below is the sample code I used. Please note <condition attribute='emailaddress1' operator='eq' value='Adrian@adventure-works.com'  is used for testing purpose. My real requirement is to filter by parentcustomerid.

    function dynamicallyFilterSubGrid() {

       //RelatedCars : is name of subgrid given on Form.

       var objSubGrid = window.parent.document.getElementById("ContactsGrid");

       //CRM loads subgrid after form is loaded.. so when we are adding script on form load.. need to wait unitil

    subgrid is loaded.

       // thats why adding delay..

       if (objSubGrid == null || objSubGrid.readyState != "complete") {

           setTimeout(dynamicallyFilterSubGrid, 2000);

           return;

       }

       else {

           //when subgrid is loaded, get category value

           // var category = Xrm.Page.getAttribute('parentcustomerid').getValue();

           //Create FetchXML for sub grid to filter records based on category

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

                               "<entity name='contact'>" +

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

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

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

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

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

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

                                   "<filter type='and'>" +

                                       "<condition attribute='statecode' operator='eq' value='0' />" +

                                       "<condition attribute='emailaddress1' operator='eq' value='Adrian@adventure-works.com' />" +

                                    "</filter>" +

                               "</entity>" +

                           "</fetch>";

         if(objSubGrid.control != null)

        {

          objSubGrid.control.setParameter("fetchXml", FetchXml);

           /*This statement will refresh the sub grid after making all modifications.*/

          objSubGrid.control.Refresh();

         }

       else {

             setTimeout(objSubGrid, 2000);

         }

       }

    }

  • Inogic Profile Picture
    Inogic 24,094 on at
    RE: I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

    Hi,

    If in case you are using any unsupported code to change Fetch Xml of the grid, then in order to allow it to work you need to set legacy form rendering to no from settings -> administration -> System setting as shown below.

    sanket1.png

    We highly recommend not to do so because in future it might affect the page rendering.

    Thanks!

    Sam

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

    Hi Drew, Thank you for the quick reply. My requirement is little bit more complex. I want a sub grid which shows contacts in contacts form which dynamically filtered by Account id. So when you open up contact record the subgrid will show all contacts related to the account attached to that specific contact record.  When you add a standard contact subgrid (showing related records), it just shows up blank. I can have a subgrid to show all active contacts in contact form, but I will need to dynamically filter records so it will only show related records to the account. Thank you   

  • Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

    Hi Dinesh,

    Refer the links below for creating subgrids in CRM 2016 Update 1.

    https://msdn.microsoft.com/en-in/library/dn932137.aspx

    https://technet.microsoft.com/en-us/library/dn920679.aspx

    Also refer the link below for adding a subgrid to related records in contacts.

    http://blog.clickdimensions.com/2015/10/adding-a-sub-grid-of-related-records-to-your-contacts.html

    https://community.dynamics.com/crm/f/117/t/155528

    http://www.magnetismsolutions.com/blog/zhenyuwang/2012/06/19/check_other_records_associate_with_current_record_using_dynamic_crm_2011_workflow

    Hope this helps.

    Thanks

  • Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: I need to have a contacts sub grid on contact form which is filtered based on Account(which is attached to the contact).

    Hi Dinesh,

    Why do you need to use FetchXML for this type of capability?  You should be able to display contacts that are related to the account through standard functionality with the subgrid.   Please provide more details on the challenge here.

    Thanks,

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans