New Xrm.Utility Functions in Update Rollup 8 for Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online

Update Rollup 8 for Microsoft Dynamics CRM 2011 was released in May but we didn’t provide an SDK update for it. As a result you probably haven’t seen a couple new client-side JavaScript functions that were added to open entity forms and web resources.
These functions were added because with Microsoft Dynamics CRM Online scripts that used in the Outlook client to open a Microsoft CRM page like a form or web resource would prompt the user to login again. The reason was that calling this function would open a new unauthenticated process. The fix added in update rollup 8 was to provide some wrapper functions so that custom JavaScript functions can use the already authenticated process.
The following is a preview of the reference topic that will be included in the next SDK update.

Xrm.Utility Reference

The Xrm.Utility object provides a container for useful functions not directly related to the current page.
These functions are available in every application page that supports scripting. You can use them in form scripts or in ribbon commands. For HTML web resources, they are available when you include the ClientGlobalContext.js.aspx page. For more information, see ClientGlobalContext.js.aspx.


The following table lists the functions of Xrm.Utility.

Function Description
openEntityForm Opens an entity form.
openWebResource Opens an HTML web resource.


Opens an entity form.



  • name
    • Type: String
    • Required: The logical name of an entity.
  • id
    • Type: String
    • Optional: The string representation of a unique identifier or the record to open in the form. If not set, a form to create a new record is opened.
  • parameters
    • Type: Object
    • Optional: A dictionary object that passes extra query string parameters to the form. Invalid query string parameters will cause an error.

      Valid extra query string parameters are:

Return Value: Window object.

Remarks: This function provides a better developer experience than the process of manipulating the URL passed to the method described in Open Forms, Views, and Dialogs with a URL. Using this function also helps ensure that users are not prompted to log in again under certain circumstances.


Open a new account record



Open an existing account record



Open a new account record with a specific form and setting default values

var parameters = {};
parameters["formid"] = "b053a39a-041a-4356-acef-ddf00182762b";
parameters["name"] = "Test";
parameters["telephone1"] = "(425) 555-1234";
Xrm.Utility.openEntityForm("account", null, parameters);


Open a new contact record, move it to the top left corner of the screen, and set the size of the window


You cannot use window object methods such as moveTo or resizeTo in scripts that will run in Microsoft Dynamics CRM for Microsoft Office Outlook.

var newWindow = Xrm.Utility.openEntityForm("contact");


Opens an HTML web resource.

Xrm.Utility.openWebResource(webResourceName,webResourceData,width, height)


  • webResourceName
    • Type: String
    • Required: The name of the HTML web resource to open.
  • webResourceData
    • Type: String
    • Optional: Data to be passed into the data parameter.
  • width
    • Type: Number
    • Optional: The width of the window to open in pixels.
  • height
    • Type: Number
    • Optional: The height of the window to open in pixels.

Return Value: Window object.

Remarks: An HTML web resource can accept the parameter values described in Passing Parameters to HTML Web Resources . This function only provides for passing in the optional data parameter. To pass values for the other valid parameters, you must append them to the webResourceName parameter.


Open an HTML web resource named “new_webResource.htm”:



Open an HTML web resource including a single item of data for the data parameter”



Open an HTML web resource passing multiple values through the data parameter

var customParameters = encodeURIComponent("first=First Value&second=Second Value&third=Third Value");


These values have to be extracted from the value of the data parameter in the HTML web resource. For more information, see Sample: Pass Multiple Values to a Web Resource Through the Data Parameter.


Open an HTML web resource with the parameters expected by HTML web resources:


For more information, see Passing Parameters to HTML Web Resources .


Open an HTML web resource, setting the height and width:

Xrm.Utility.openWebResource("new_webResource.htm", null, 300,300);