Microsoft Dynamics CRM 2011 – Hierarchical Treeview – Version 0.1


Rémi Boigey, Partner Technical Consultant @ Microsoft France, did a great Silverlight application (version 0.1) for  Microsoft Dynamics CRM 2011 that we share you today.

Solution Features

  • Dynamically display associated entities with the current record.
  • You can customize the display.
  • You can open records from the list


Next Features

  • Create a user interface in order to customize the view without coding.


Step 1 : Save the CRM solution on your disk -

Step 2 : Import the solution – Settings / Solutions / Import


Click on Browse Button and select the solution

Click on next buttons and close the form.

Test the solution

In order to test the solution, We provide you a pre-configuration file for an account inside the solution.

In Settings/Customization/Customizations/Customize the System, select the account entity and edit the main Form.

Edit or add a new section.

Click on Insert tab, and then select Web resource 'Hierarchical Related Entity (Account sample).html'




Save and publish the account form.


You can reuse and customize this solution for different entities, to do this follow the following steps :

  • Create a new HTML web resource (either in the default solution or in a custom solution)
  • Copy and paste the following code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<title>Sample hierarchical Related Entity</title>
<style type="text/css">
html, body {
height: 100%;
overflow: auto;

body {
             padding: 0;
             margin: 0;
    #silverlightControlHost {
             height: 100%;

    <script type="text/javascript" src="gps_scripts/Silverlight.js"></script>
    <script type="text/javascript" src="gps_scripts/hierarchicalrelatedentity.js"></script>
    <script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>
    <script type="text/javascript">

        var slConf = '<?xml version="1.0"?>' +

                        '<hierarchies xmlns:xsi="" xmlns:xsd="">' +

                            '<hierarchy entity="account" pk="accountid" icon="gps_imgs/ico_account.png" displayField="name"  UrlBody="/main.aspx?etc=1" UrlBodyExtra="extraqs=id=" UrlSuffix="pagetype=entityrecord">' +

                                '<relatedEntity  name="activitypointer" pluralName="Activités" pk="activityid" fk="regardingobjectid" displayField="subject|string,ownerid|EntityReference,scheduledstart|System.DateTime,scheduledend|System.DateTime" icon="gps_imgs/ico_activity.png" UrlBody="userdefined/edit.aspx?etc=4212" UrlBodyExtra="id=" UrlSuffix=""  />' +

                                '<relatedEntity  name="opportunity" pluralName="Opportunités" pk="opportunityid" fk="customerid" displayField=
"name|string,estimatedvalue|Money,estimatedclosedate|System.DateTime,closeprobability|int,ownerid|EntityReference" icon="gps_imgs/ico_opportunity.png"  UrlBody="main.aspx?etn=opportunity" UrlBodyExtra="extraqs=id=" UrlSuffix="pagetype=entityrecord"  />' +

                                '<relatedEntity name="contact" pluralName="Contacts" pk="contactid" fk="parentcustomerid" displayField="fullname" icon="gps_imgs/ico_contact.png"   UrlBody="main.aspx?etn=contact" UrlBodyExtra="extraqs=id=" UrlSuffix="pagetype=entityrecord" />' +

                                '<relatedEntity  name="account" pluralName="Sous-Comptes" pk="accountid" fk="parentaccountid" displayField="name" icon="gps_imgs/ico_subaccount.png"  UrlBody="main.aspx?etn=account" UrlBodyExtra="extraqs=id=" UrlSuffix="pagetype=entityrecord" />' +
                            '</hierarchy>' +


<form id="form1" runat="server" style='height:100%'>
<div id="silverlightControlHost">
<script type="text/javascript">

The display is done in JavaScript in the variable named “slConf”. This variable contains data in XML.


  • Hierarchy :Represents the current entity


  • entity : schema name of the entity
  • pk : primary key of the entity
  • icon: url

For information you can use your own pictures, for that you must import them into the CRM as a web resource.

If there are several attributes, you must use the separator ‘|’ between type and schema name and use a comma to separate different fields



UrlBody, UrlBodyExtra ,UrlSuffix : are used to build record url


  • relatedEntity : represents an entity linked to the current record


  • entity,pk,icon,displayField : see previous definition
  • fk : foreign key
  • pluralName:

relatedEntity: represents an entity linked to the current record

This code samples is provided "AS IS" without warranty of any kind.
We appreciate any feedbacks, so feel free to contact Remi BOIGEY |


Comments (24)

  1. Olivier says:

    Excellent work from you guys! And special thanks to Remi for providing this useful add-on to Microsoft CRM 2011 🙂

  2. NAG says:

    Not working for me. Its giving blank and no error.

  3. Hi,

    Nice article but when I tried to use it with the same steps you specified, I got nothing in the tab. It was all blank with no error in event viewer. However Silver-light 4.0 was installed on my machine. I tried on different machine and it worked. There doesn't seems to be any apparent differences in both machine. Any Idea?


  4. Abhishek says:

    Works great…

    Thanks for this component …

    Can you share the code for Silverlight xap as i will have to customize it a bit to meet my requirements 🙂

  5. Great article, but its showing a blank screen. Can you please double check?

    We have followed steps AS-IS.


  6. says:

    Would this work with CRM Online too?

  7. Dattatray says:

    I followed all step as given by u.its not showing the required output…

  8. Florin says:


    Can you share the code for xap, please? Or, if not, will this be able to go upwards as well? Let's say the current account/contact has a parent. Will it show it on top of it?



  9. says:


    How to make this recursively (to show more layers of related entities)?

  10. For those who have commented that they're not seeing any content with this, be sure to check the "Pass record object-type code and unique identifier as parameters" checkbox at the bottom of the General tab in the Web Resource Properties dialog.

    This is a great looking tool but I'd like to be able to use it to display all my accounts and sub-accounts in a single tree. Can you provide some guidance on how to set up the HTML or modify the javascript to achieve this. I tried passing a null and empty guid to the control in the javascript but this causes an error.

  11. R Tebar says:


    Thanks for this useful and simple hierarchy viewer. It works fine for me but when I click in a related record (e.g. contact linked to parent account), it opens a wrong URL address missing ' / ' between the organisation name and 'main.aspx?etn=', so it looks like this:


    Does it happen for you guys?


  12. R Tebar says:

    *** Forget my previous post ***  still sleeping in London time, It was an easy change in the configuration webresource 😛


  13. Patrick Sma says:

    Hi Ramon,

    I have the same issue " it opens a wrong URL address missing ' / ' between the organisation name and 'main.aspx?etn='"

    Could you please tell me how you fixed it ?

    Thanks for your help.

  14. Jeevan says:

    Getting this error when i deployed this solution in one of my environment, any idea?

    Message: Unhandled Error in Silverlight Application

    Code: 2104    

    Category: InitializeError      

    Message: Could not download the Silverlight application. Check web server settings    

    Line: 57

    Char: 5

    Code: 0

    URI: http://CRM2011/OrgName/%7B634945435850000000%7D/WebResources/gps_scripts/hierarchicalrelatedentity.js

  15. Great work Remi. It just works. Trying to change the Language to English.

  16. Issue in OnPremise says:

    Hi Guys,

          I deployed this in 3 different CRM online instances and one Onpremise and all worked fine but in another onpremise(workgroup) environment i was getting no result in the grid.

    So here are the steps

    1. Open the hierarchicalrelatedentity.js and at the bottom


    Silverlight.createObject(serverUrl + "WebResources/gps_ClientBin/SLHierarchicalRelatedEntity.xap",

               divSLId, "slPlugin",


    Silverlight.createObject(serverUrl + "/WebResources/gps_ClientBin/SLHierarchicalRelatedEntity.xap",

               divSLId, "slPlugin",

    2. make sure that you enabled Anonymous access to .svc file. If you don't you will see an error in the Event longs. Check the error and correct it accordingly and make sure that

    you    Restart IIS after that.

    Please correct me if i'm wrong.



  17. Ostap says:

    I wonder what would be the performace of this application on real data?

  18. Seamus says:

    Hello – this is great – thanks very much! Just wondering what I would need to do to have the company name expanded on load – to save me having to click on the company name to access the related entities? Thanks again,

  19. Ameed says:

    Hello Remi,

    As Florin also asked above for the code. We wish to change it for same situation in order to show from parent records. Secondly, though one can open contacts, opportunities and activities by double clicking in the respective node, it is not possible to open a sub account in edit mode by double click. It always opens the sub hierarchy below the account instead of opening the edit form of sub-account

  20. Endy says:

    Great tool.

    But for some reasons, the base entity starts somewhere in the middle of the "Web Resource box" on my form instead of on top.

    Someone knows how this comes?

  21. Thomas says:


    It seems that the component Hierarchical Treeview is not working on a CRM 2013 organization.

    I get an error when the component is loaded on the account form:

    Exception: [HttpWebRequest_WebException_RemoteServer]

    Argument : Not Found

    The exception is triggered by the RetrieveEntity_ClickCallback() function.

    Can you please confirm that bug and, if necessary, provide the fix?

    Thank you for this awesome component!

    Best Regards,

  22. Seamus says:


    Is there any way of referencing an entity via a Many to Many relationship  – I tried using the relationship name as the foreign key and it didn't work. Any ideas very welcome, thanks.

  23. Seamus says:


    In CRM 2013 the treeview does not appear – it flashes "100%" but then nothing appears in the Grid. There is no error message. This is a great solution and it would be a real shame if it did not function correctly in 2013. Any suggestions would be very welcome. Thanks again.

  24. Seamus says:

    Hi, – not sure if you are checking these, but is there any easy way to exclude deactivated records from output?

    Thanks again.

Skip to main content