Microsoft Dynamics CRM 2011 – Pass Parameters to a URL By Using the Ribbon


Ribbon actions are defined in the <Actions> (RibbonDiffXml) element of a <CommandDefinition> (RibbonDiffXml) element. There are several ways to pass contextual Microsoft Dynamics CRM information as query string parameters to a URL by using the ribbon.

  • Use a <Url> (RibbonDiffXml) element. Within the URL element, use the PassParams attribute.
  • Use a <Url> (RibbonDiffXml) element together with a <CrmParameter> (RibbonDiffXml) element. When used from a URL element, the name attribute value must be set.
  • Use a <JavaScriptFunction> (RibbonDiffXml) element together with a <CrmParameter> (RibbonDiffXml) element.

Use the PassParams Attribute to Set Dynamic Values

Passing parameters to the target URL by using the PassParams attribute provides information to the target application about the context of the record or the user. All the parameters are passed if the ribbon control is configured by using the PassParams attribute. The following table lists the parameters that are passed.

Parameter: typename

  • Name: Entity Name
  • Description: Name of the entity. For custom entities, this includes the customization prefix, for example, new_entityname.

Parameter: type

  • Name: Entity Type Code
  • Description: Integer that uniquely identifies the entity in the current organization. Note: Entity Type Code values are determined by the order in which an entity is created in an organization. Entity Type Codes for custom entities are usually different in different organizations.

Parameter: id

  • Name: Object GUID
  • Description: Globally unique identifier (GUID) that represents a record.

Parameter: orgname

  • Name: Organization Name
  • Description: Unique name of the organization.

Parameter: userlcid

  • Name: User Language Code
  • Description: Language code identifier that is used by the current user.

Parameter: orglcid

  • Name: Organization Language Code
  • Description: Language code identifier that represents the base language for the organization.

Language codes are four-digit or five-digit locale IDs. Valid locale ID values can be found at Locale ID (LCID) Chart).

Note: We recommend that you use the entity name instead of the entity type code because the entity type code may be different between Microsoft Dynamics CRM installations.

Example

The following sample shows shows the URL without parameters:

The following sample shows shows the parameters included when the ribbon control is presented for the account entity, for an organization called ‘AdventureWorksCycle’, when the user’s language and the organization base language is English, and the GUID for the account record is DBD5DBFB-0666-DC11-A5D9-0003FF9CE217:

Use a Querystring Parameter in the URL

You can include a querystring parameter in the URL attribute. This can be very useful if you want to open a specific Microsoft Dynamics CRM record or view by using Open Forms, Views, and Dialogs with a URL.

  • Note: You will not be able to import the ribbon if the URL includes the ampersand (&) character that is used to separate multiple querystring parameters in the URL. This character makes the XML invalid. You must escape the ampersand character in the URL attribute value with “&amp;”.

Reading Passed Parameters

Passed parameters are usually read in the target .aspx page by using the HttpRequest.QueryString property. For more information, see http://msdn2.microsoft.com/en-us/library/system.web.httprequest.querystring.aspx.

  • Note: If the target of your URL is a Web resource, it can accept only the parameters identified in the topic Passing Parameters to HTMLWeb Resources. The only opportunity to pass custom values is by including them within the data parameter. Some special handling is required to include multiple values in a single parameter. For more information, see Sample: Pass Multiple Values to a Web Resource Through the Data Parameter.

My above blog is based on Microsoft’s Official information.

I hope this blog about ‘Microsoft Dynamics CRM 2011 – Pass Parameters to a URL By Using the Ribbon’ was informative. Please feel free to leave your comments.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Comments

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

%d bloggers like this: