Pass Custom Parameters to an entity form through a URL

By | February 1, 2012

In your applications, you may want to pass custom query string parameters to an entity form.
Let me describe the way in which we can define a set of specific parameter names and data types that can be accepted for a specific entity form.

Define Allowed Query String Parameters:
There are two ways to specify which query string parameters will be accepted by the form:
• Edit form properties
• Edit form XML

Edit Form Properties:
When you edit an entity form, on the Home tab in the Form group, click Form Properties. In the Form Properties dialog box, select the Parameters tab. Use this tab to modify the names and data types that the form allows as given in the below screen shot.

The following describes the querystringparameter element attributes, name and type:Name: Each name attribute must contain at least one underscore (‘_’) character, but the name of the query string parameter cannot begin with an underscore. The name also cannot start with ‘crm_’. We strongly recommend that you use the customization prefix of the solution publisher as the naming convention. If you don’t follow the naming conventions the alert message as given in the below screen shot will be shown to the user.

Type: Following types of parameters can be passed to the form. Match the data type values with the parameter values so that invalid data is not passed with the parameter. The following are valid data types:
• Boolean
• DateTime
• Double
• EntityType
• Integer
• Long
• PositiveInteger
• SafeString
• UniqueId
• UnsignedInt

Let me define the parameters for the form and access them through Query string parameters.

– We have created two parameters for the Account Form as given in the below screen shot.

– We have opened the form through the below given script with parameters appended to the URL.
var extraqs = “Parameter_Source=Hello”;
extraqs += “parameter_Source2=8”;
//Set features for how the window will appear.
var features = “location=no,menubar=no,status=no,toolbar=no”;
// Open the window. +”/main.aspx?etn=account&pagetype=entityrecord&extraqs=” + encodeURIComponent(extraqs), “_blank”, features, false);

– After that we have checked it through the query string parameters.
// Get the Query String Parametrs passedthrough the URL
var param=context.getQueryStringParameters();
// Get the Value of the Source through the Key Parameter Name
var source=param[“Parameter_Source”];
var source2=param[“parameter_Source2”];
// if Source is Undefined i.e. the URL Doesn’t contain the key
if (source==undefined){ return; }
else{ // Perform the operation

This will be helpful in the scenario suppose if are opening the Form through the different sources such as Silverlight, report etc. and on the form load you want to perform some operation based on the source then you can define parameter for the form and can pass the source name in the extraqs of the URL as mentioned above and can check the source name on the form load and can perform the operation accordingly.

Free 70% of storage space in CRM with Attachment Management Apps!

Attach2Dynamics – Store and manage documents/attachments in cloud storage of your choice – SharePoint, Dropbox or Azure Blob Storage from within Dynamics 365 CRM.
SharePoint Security Sync – Robust and secure solution to integrate Dynamics 365 CRM and SharePoint Security Sync thereby ensuring secure access to confidential documents stored in SharePoint.

3 thoughts on “Pass Custom Parameters to an entity form through a URL

  1. Erdem


    I have an issue with this, when I refresh the page, the parameter is missing. Do you have any solution for this?

    1. Inogic Post author

      Hi Erdem,

      Query String parameters are used if you want to create an entity record with some pre-defined set of values. These values will be passed as a parameter in the URL which opens the form.

      Also, when the form containing the query string parameters is loaded, the URL still remains the same as the default URL, and parameter values are set on the different fields in the form.

      But when a page is refreshed, CRM does not get any parameter values for the defined parameters so it just loads the default URL without setting any parameter values for any of the fields on the form.

      Hope this helps!

Comments are closed.