locked
Unable to view Parent record in Child record using fetchxml RRS feed

  • Question

  • Hi All,

    I am using FetchXml to get child records into parent but unable to view the parent record in Child. It has 1:N releationship. But its to the same entity. I want to display records from same entity to same entity.

    TIA

    Tuesday, November 5, 2013 11:43 AM

Answers

  • Hi

    Check your subgrid Data Source settings, use All Record Types. And set Open Activities as the default view which ever suites your needs.

    -----------------------------------------

    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful" Thank you, Sorde


    • Marked as answer by Jyothi BVL Tuesday, November 26, 2013 11:33 AM
    Tuesday, November 26, 2013 10:20 AM

All replies

  • This should be possible, but you'll need to supply more information if you want any useful help. What FetchXml do you have, and where are you using it ? Do you have any error messages ?

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Tuesday, November 5, 2013 4:46 PM
    Moderator
  • Hi ,

    Sorry for late reply. Below is the code which i am trying to fix. I am facing this issue in UR 14.

    function updateSubGrid() {
        debugger;
        //This will get the related products grid details and store in a variable.
        var relatedAccounts = document.getElementById("Related"); // Your Grid Unique Name
        //Initializing the lookup field to store in an array.
        var lookupfield = new Array;
        //Get the lookup field
        lookupfield = Xrm.Page.getAttribute("abc").getValue(); // Filter Grid base on the lookup value
        //lookupfield = Xrm.Page.getAttribute("twcbg_twcbg_relatedengagementsid").getValue(); // Filter Grid base on the lookup value
        //This will get the lookup field guid if there is value present in the lookup
        if (lookupfield != null) {
            var lookupid = lookupfield[0].id;
        }
        //Else the function will return and no code will be executed.
        else {
            return;
        }
        //This method is to ensure that grid is loaded before processing.
        if (relatedAccounts == null) {
            //This statement is used to wait for 2 seconds and recall the function until the grid is loaded.
            setTimeout('updateSubGrid()', 2000);
            return;

        }

        var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
        fetchXml += "<entity name='Engage'> <attribute name='id'/> <attribute name='name' /> <attribute name='area' />  <filter type='or'>";
        fetchXml += "<condition attribute='twcbg_relatedid' operator='eq' value='" + lookupid + "'/>";
        fetchXml += "<condition attribute='id' operator='eq'  value='" + lookupid + "'/>";

        fetchXml += "</filter>";
        fetchXml += "</entity>";
        fetchXml += "</fetch>";
        //Setting the fetch xml to the sub grid.
        relatedAccounts.control.SetParameter("fetchXml", fetchXml);
        //This statement will refresh the sub grid after making all modifications.
        relatedAccounts.control.refresh();
    }

    No error is showing and the grid is getting refreshed also but no records are coming up. Also i check the same query in advance find its showing up records.

     


    • Edited by Jyothi BVL Tuesday, November 26, 2013 9:48 AM
    Tuesday, November 26, 2013 9:37 AM
  • Hi

    Check your subgrid Data Source settings, use All Record Types. And set Open Activities as the default view which ever suites your needs.

    -----------------------------------------

    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful" Thank you, Sorde


    • Marked as answer by Jyothi BVL Tuesday, November 26, 2013 11:33 AM
    Tuesday, November 26, 2013 10:20 AM
  • Hi,

    Whenever you want to check such scenario, the best way is to debug the webpage to verify the steps, this will help to check whether the value are being populated into the js fields.

    Incase you are not receiving the values in the JS fields itself, then you need to look into the query and debug.

    You can also give a try to this code:

    relatedAccounts._control.get_innerControl().SetParameter("fetchXml", fetchXML);

    Once you verify that the value is being populated into the JS fields then you need to look into the view of the grid if it is selected as the "Include Related Records" in the dropdown of the subgrid.

    I hope this should resolve your issue.

    Thanks & Regards,



    Anubhav Bajpai


    • Edited by Anubhav Bajpai Tuesday, November 26, 2013 11:34 AM updated code snippet
    Tuesday, November 26, 2013 11:18 AM
  • Thanks alot , it really fixed the issues which i was trying from long time.

    Another query , is it specific to UR 14 or something or in general we have set the grid properties , becuase i think CRM 2013 we need not explicitly set it.

    Tuesday, November 26, 2013 11:33 AM