locked
fetch XML help - Stuck on last point!!! How can i set up subgrid? RRS feed

  • Question

  • Hi all, could someone help me please with some ideas how to approach below issue..

    SET UP: 
    “Account Form” has two fields: "Child" and "Parent "
    “Account Form” has sub-grid: "Strategy" - which pulls strategies from "Account Strategy Form"

    "Account Strategy Form" – has lookup for “Child” or “Parent” 
     
    ACTION:
    Create “Account Strategy” entries for both: "Child" and "Parent"

    ISSUE:
    Under my “Account Form” sub-grid “Strategy” I now want to see strategies for both “Child” and “Parent”

    Is there a way to use fetchXML option to set it up in my subgrid so I can see both of my strategies show up?

    Tuesday, October 15, 2013 12:16 PM

All replies

  • Hi Donyc,

    There is a blog post about how to set up you subgrid view to utilize fetchXML:

    http://www.magnetismsolutions.com/blog/paul-nieuwelaars-blog/2013/01/24/filter-sub-grid-dynamics-crm-2011-rollup-12-(polaris)

    Tuesday, October 15, 2013 2:34 PM
  • var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
        "  <entity name='strategy'>" +
        "    <attribute name='child' />" +
        "    <attribute name='parent' />" +

        "    <attribute name='strategyid' />" +
        "    <attribute name='accountid' />" +
        "    <filter type='and'>" +
        "      <condition attribute='accountid' operator='eq' uitype='strategy' value='" + accId + "' />" +
        "    </filter>" +
        "    <link-entity name='account' from='accountid' to='accountid' visible='false' link-type='outer' alias='a'>" +
        "      <attribute name='child' />" +

        "      <attribute name='parent' />" +
        "    </link-entity>" +
        "  </entity>" +
        "</fetch>";

    • Proposed as answer by RameshwariSah Tuesday, October 15, 2013 6:48 PM
    Tuesday, October 15, 2013 6:48 PM
  • Hi,

    i have done the same thing seems to be. I think this may help you. Please go through this link.

    http://srmscrm.wordpress.com/category/ms-crm-2011/ms-crm-2011-subgrids/


    Warm Regards, Suresh Kumar D

    Wednesday, October 16, 2013 2:25 AM
  • Thanks all for the feedback. To a total newbie who is very unfamiliar with fetchXML, where would I start with by adding the below code? I can't seem to find any tutorials on this subject.

                  

    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
        "  <entity name='strategy'>" +
        "    <attribute name='child' />" +
        "    <attribute name='parent' />" +

        "    <attribute name='strategyid' />" +
        "    <attribute name='accountid' />" +
        "    <filter type='and'>" +
        "      <condition attribute='accountid' operator='eq' uitype='strategy' value='" + accId + "' />" +
        "    </filter>" +
        "    <link-entity name='account' from='accountid' to='accountid' visible='false' link-type='outer' alias='a'>" +
        "      <attribute name='child' />" +

        "      <attribute name='parent' />" +
        "    </link-entity>" +
        "  </entity>" +
        "</fetch>";

    Thursday, December 12, 2013 10:04 PM
  • Hi Donyc, to do this, You need to write some js code on load of Account Form,

    make sure below grid id should be same and you need to get account id also 

     var strategyGrid= document.getElementById("Strategy");

    function UpdateSubGrid() 
    {
     var strategyGrid= document.getElementById("Strategy");
     
     if (strategyGrid==null || strategyGrid.readyState != "complete") 
     {    
    
     setTimeout('UpdateSubGrid()', 1000);     
     return;  
    }
     //Update the fetchXML that will be used by the grid.  
    
    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
        "  <entity name='strategy'>" +
        "    <attribute name='child' />" +
        "    <attribute name='parent' />" +
    
        "    <attribute name='strategyid' />" +
        "    <attribute name='accountid' />" +
        "    <filter type='and'>" +
        "      <condition attribute='accountid' operator='eq' uitype='strategy' value='" + accId + "' />" +
        "    </filter>" +
        "    <link-entity name='account' from='accountid' to='accountid' visible='false' link-type='outer' alias='a'>" +
        "      <attribute name='child' />" +
    
        "      <attribute name='parent' />" +
        "    </link-entity>" +
        "  </entity>" +
        "</fetch>";
    
     //Inject the new fetchXml  
    strategyGrid.control.setParameter("fetchXml", fetchXml);  
    //Force the subgrid to refresh  
    
    strategyGrid.control.refresh(); }


    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".



    • Edited by san Sanz Thursday, January 2, 2014 7:05 AM
    Thursday, January 2, 2014 7:03 AM