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,…)

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. 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!