Change subgrid view dynamically by Javascript RRS feed

  • Question

  • Hello,

    In my current project Client would like an activities view that shows related activities PLUS some fields from those activities.

    Please let me know how to change subgrid view dynamically.

    we are trying to get the same results as in the out of the box subgrid where you get the regarding activities but we want some additional fields such as the To from the phone call activity

    I am using below code to achieve this

    // JavaScript source code
    //Change the Fetch XML and set the subgrid ID
    function UpdateSubGrid()
        var SubGrid = document.getElementById("Activities");
        if (SubGrid.readyState != "complete")
            //The subgrid hasn't loaded, wait 1 second and then try again
            setTimeout(UpdateSubGrid, 1000);

        var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' >" +
      "<entity name='activitypointer'>" +
       " <attribute name='subject' />" +
        "<attribute name='ownerid' />" +
        "<attribute name='prioritycode' />" +
        "<attribute name='regardingobjectid' />" +
        "<attribute name='activitytypecode' />" +
        "<attribute name='statecode' />" +
        "<attribute name='scheduledstart' />" +
        "<attribute name='scheduledend' />" +
        "<attribute name='activityid' />" +
        "<attribute name='instancetypecode' />" +
        "<attribute name='community' />" +
        "<order attribute='scheduledend' descending='false' />" +
        "<filter type='and'>" +
        " <condition attribute='isregularactivity' operator='eq' value='1' />" +
        "</filter>" +
        "<link-entity name='phonecall' from='activityid' to='activityid' visible='false' link-type='outer' alias='phonecalllinkage'>" +
        " <attribute name='from' />" +
        " <attribute name='to' />" +
        "</link-entity>" +
        "<link-entity name='task' from='activityid' to='activityid' visible='false' link-type='outer' alias='tasklinkage'>" +
        " <attribute name='percentcomplete' />" +
        "</link-entity>" +
        "</entity>" +

       // fetchXml
        //Set Fetch XML
        //Inject the new fetchXml..
        SubGrid.control.SetParameter("fetchXml", fetchXml);
        //Force the subgrid to refresh



    Many thanks in advance.


    • Edited by Harsha1525 Tuesday, March 17, 2015 2:02 PM more clarity
    Monday, March 16, 2015 12:53 PM

All replies

  • Hi Harsha,

    Could you elaborate some more on the objective here? 

    I understand you'd like to add columns to your Subgrid from related entities and create filters on the view. Both are possible out of the box customizations - Set up a view with the filters you'd like and add columns from the record you're on / or columns from related entities, then use the view on your subgrid.

    I'm guessing you'd like the filters on this view to be dynamic? You could attempt to change the subgrid's FetchXML via JScript but that is not supported.

    Tuesday, March 17, 2015 11:33 AM
  • Hi Pedro,

    Thank you for your response.

    Actual requirement is Client would like an activities view that shows related activities PLUS some fields from those activities. I tried out of box this first but it is not achievable because some entities are not available in entities list to select columns.

    I want to add coulns from related entity inside grid.

    Please let me know how I can achieve this through IFrame, Plugin or ssrs report?

    Thanks in advance.


    Tuesday, March 17, 2015 1:08 PM
  • I'm not sure you can achieve this because of the nature of the 1:N relationship between entities and activities.

    For example, if you wanted to show a view of Accounts, and also show some fields from related activities, there are potentially MANY activities related to the Account, so how do you know which ones to show?  The CRM grid doesn't support a child grouping of related activities out of the box, so perhaps a web resource would be the way to go?

    SSRS is also an option where you have u more flexibility in how to show/format the data on the report with groups and sub-groups.

    Tuesday, March 17, 2015 1:35 PM