Dynamics CRM 4 with Silverlight Part 1 – The IFRAME approach.
Introduction
29/72010: Sorry but I am going to be dropping this series because my software focus has change to developing Windows Phone 7 applications. Maybe re visit this in the future (hopefully before CRM 5 is released ![]()
Hi, this is part 1 of a series of posts giving an introduction to extending Microsoft Dynamics using Silverlight.
In this post I will outline how to add a custom Silverlight control to any of the entity forms.
For these articles I will be using Visual Studio 2010 Professional with All of the usual Silverlight (version 4) tools installed.
At Sequence the company where I work we make use of the eService accelerator this allows our customers to log cases via an extension to our web site. For this series of posts I am going to create a new tab in the contact entity screen that will display details of the contacts log in details that are stored in a separate ASP.NET authentication database.
How it works
The CRM 4 entity forms allow administrators to customise forms in many different ways but the one way that makes things handy for us is the ability to add IFRAME elements into a form. We will use this customisation to display a Silverlight control inside the form.
Getting Started
Create a new Silverlight application as normal ensuring that you enable RIA services and create a test web project.
NOTE: In future when you will want to make this live you will need a server available that you can add the .Net framework 4 and host the web site or virtual directory.
Identifying the Entity
So that the Silverlight application knows what entity it is using it will need to be passed the Id of the entity that is being displayed in the entity form. To ensure that this works when you add an IFRAME customisation to an entity you will need to ensure that the I frame is passed the record ID and type:
This results in the following URL:
To get these values into my Silverlight application I have decided to use Silverlight parameters. To do this I first added the following code to the ASPX page that displays the application:
public string SilverlightParams
{
get
{
Request["id"], Request["type"], Request["orgname"], Request["typename"]);
return sRes;
}
}
Then in the page mark-up I added the following to the params for the Silverlight application:
<param name="initParams" value="<% = SilverlightParams %>" />
So we get this:
width="100%" height="100%">
value="ClientBin/Sequence.CRM.SilverlightExtensions.MainDashboard.xap"/>
style="text-decoration:none">
alt="Get Microsoft Silverlight" style="border-style:none"/>
In the Silverlight application project I added the following to the App class code:
{ { } } In the Application_Startup method:
{ m_ContactID = this.RootVisual = new MainPage();
} We can now access the ContactID anywhere in the code like this:
(( Here is a screenshot of a simple app in an I frame just to show it works: In part 2 I will show how to hook this app up to the ASP.NET authentication database.
Making the App Know the entity Id
Just checking
