Reading URL-parameters in Silverlight

There are two ways to read URL-parameters in Silverlight. Today I am going to show you one, and the easiest according to me.

In CRM there is a setting that you can “pass-param”. If you are on a CRM Form you get keys like “typename” and “id”.

Complete list (CRM 2011):

Parameter Name Description
typename Entity Name Name of the entity
type Entity Type Code Integer that uniquely identifies the entity in a specific organization
id Object GUID GUID that represents a record.
orgname Organization Name Unique name of the organization.
userlcid User Language Code Language code identifier that is being used by the current user.
orglcid Organization Language Code Language code identifier that represents the base language for the organization.

Example:

http://myserver/mypage.aspx?id=%7bB2232821-A775-DF11-8DD1-00155DBA3809%7d&orglcid=1033&orgname=adventureworkscycle&type=1&typename=account&userlcid=1033

If you have the Silverlight in the Sitemap you don’t get (of course), typename, type and id.

You can read them in your Silverlight:

 1: IDictionary<string, string> QueryString = HtmlPage.Document.QueryString;
 2: string orgname, entityname;
 3:
 4: if (QueryString.ContainsKey("orgname"))
 5:     orgname = QueryString["orgname"];
 6:
 7: if (QueryString.ContainsKey("typename"))
 8:     entityname = QueryString["typename"];
Advertisements
This entry was posted in CRM 2011, CRM 4, MS CRM and tagged , , . Bookmark the permalink.

One Response to Reading URL-parameters in Silverlight

  1. Rodrigo says:

    Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s