Friday, June 8, 2012

Microsoft Dynamics CRM 2011 – Hierarchical Treeview

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.

No comments:

Post a Comment