Set Record Fields Values and Open Views With an URL

In Microsoft Dynamics CRM 2013 you can link an external application or add a button somewhere to access the creation form of an entity or a view with simple querying in the organization URL. Entities and Views can be displayed by passing parameters to the main.aspx page. There are many parameters that can be used (More details hereĀ http://msdn.microsoft.com/en-us/library/gg328483.aspx). To open a record or a view, you only need two main parameters:

  • etn: which must contain the entity name (ex: account, contact, opportunity,…)
  • pagetype: this takes only two values:
    • entityrecord: Opens an entity record;
    • entitylist: Opens an entity view.

Examples:

But how to open a new record with predefined values?

Suppose you want to add a creation button in the CRM to an external application. It may be useful to open the creation form in the CRM with some predefined values. So here is how to set field values by passing parameters directly to the form: In addition to the two parameters presented above (entityrecord and entitylist), the third parameter to consider here is extraqs. The parameters passed to etraqs must first be encoded (See http://msdn.microsoft.com/en-us/library/gg334375.aspx for more details). Passing parameters may be different when the field type is date, lookup or text. For date fields, you should use the text value of the date. Example: Creating an Account with the predefined value “My Account”. The encoded value for the extraqs is name=”My Account” http://YourCRMAddress/main.aspx?/main.aspx?etn=account&extraqs=name%3DMy%20Account&pagetype=entityrecord To set more field values, you should first use the encodeURIComponent function and then copy/paste the result and replace the bold part of the URL above. my account Getting the encodedURIComponent by using Javascript: You can use this to get the encodedURI. In this example I try to get the encodedURI of “name=My Account & numberofemployees=20”. <html> <script> var URI = “name=My Account&numberofemployees=20”; var result = encodeURIComponent(URI); document.write(result); </script> </html> This returns: name%3DMy%20Account%26numberofemployees%3D20 Now let’s use it to set the field values by entering the URL: http://YourCRMAddress/main.aspx?/main.aspx?etn=account&extraqs=name%3DMy%20Account%26numberofemployees%3D20&pagetype=entityrecord Yes it works! my account

Advertisements

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