Displaying Associated Views from Other Entities

Displaying Associated Views from Other Entities

Sometimes, just as we would have a Navigation link that displays an IFRAME, we would like to display a View from another entity in there.

The Solution is pretty simple. We create the navigation links, provide the Url of the of the Related Entity View and finally use the loadIsvArea JavaScript function to display the results, as shown in the example below.

Sometimes, just as we would have a Navigation link that displays an IFRAME, we would like to display a View from another entity in there.

The Solution is pretty simple. We create the navigation links, provide the Url of the of the Related Entity View and finally use the loadIsvArea JavaScript function to display the results, as shown in the example below.

The following example displays the Activities and Closed Activities of a custom entity in of the Marketing List Form. The function receives as a parameter the ID of the record that I want to display and the entity type code (etc) of the related entity.

function SetInteractions(listid, etc) 
{
  var items = Xrm.Page.ui.navigation.items.get();
    for (var i in items)
    {
      var item = items[i];
      var label = item.getLabel();
      var id = item.getId();

      if (label == "Activities")
      {
         var urlActivities = encodeURI("areas.aspx?formid=56ac0775-3315-4971-9b61-9fa6548d8935&navItemName=Activities&oId=" + listid + "&oType=" + etc + "&pagemode=iframe&security=65591&tabSet=areaActivities");
         urlActivities = serverUrl + "/UserDefined/" + urlActivities;

         var navActivities = document.getElementById(id);
         navActivities.onclick = function () { loadIsvArea(Mscrm.CrmUri.create(urlActivities), false); }
        }

      if (label == "Closed Activities")
      {
         var urlHistory = "areas.aspx?formid=56ac0775-3315-4971-9b61-9fa6548d8935&navItemName=Closed%20Activities&oId=" + listid + "&oType=" + etc + "&pagemode=iframe&security=65591&tabSet=areaActivityHistory";
         urlHistory = serverUrl + "/UserDefined/" + urlHistory;  

         var navHistory = document.getElementById(id);
         navHistory.onclick = function () { loadIsvArea(Mscrm.CrmUri.create(urlHistory), false); }
      }
   }
}

Note: The code above applies to Microsoft Dynamic CRM 2011 and is not supported in future releases of CRM.