Open Entity Form javascript function in CRM 2013

Hello everyone,

In this article, I will talk about how to use open entity form javascript function in CRM 2013.

With the help of this function we can open a form from a javascript call without clicking on a button on CRM.

Open Create New Record Form

Below function opens a create new record form with the entity logical name that you passed as a parameter to it.

// opens new create record form
function openCreateForm(LogicalName) {
    try {
    } catch (e) {

If you want to call this function on Load event of the Form you can write a function to be called on Load you can write a javascript function like this:

function formOnLoad() {


openEntityForm Function in Detail

Actually openEntityForm function takes 3 parameters. As I will explain below we only used the name parameter in above code which is the required parameter. But there are also 2 more optional parameters as well: id and parameters



 openEntityForm Function Parameters

name: This represents the logical name of an entity. Parameter type is string. And using this parameter as I mentioned above is mandatory since it is a required parameter.

id: This represents a unique identifier of the record to open in the form. Parameter type is string and it is optional. If this parameter is not set, openEntityForm function opens a create new record form. If you set this parameter you will see an existing record’s form when you call openEntityForm function with javascript.

parameters: This is a dictionary object which passes extra query string to the form. Using this parameter is optional. If you pass invalid query string to this parameter this will cause an error.

Let’s make some examples for what I mentioned above to be well-understood.

Example 1: Open an existing contact record


Example 2: Open a new contact record with a specific form and set its default values

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


All I’ve talked about was to open an entity form on the current form which you are using at a time. But what if you want to open a new window for the entity?

Here is an example about how to open a new create contact record form in a new window :

function OpenNewContact() {
    var parameters = {};
    //Set the Parent Customer field value
    parameters["parentcustomerid"] = "4478282E-94D6-E111-9B1D-00155D9D756B";
    parameters["parentcustomeridname"] = "test";
    parameters["parentcustomeridtype"] = "account";
    //Set the Address Type to “Primary”.
    parameters["address1_addresstypecode"] = "3";
    //Set text in the Description field.
    parameters["description"] = "Default values for this record were set programmatically.";
    //Set Do not allow E-mails to "Do Not Allow".
    parameters["donotemail"] = "1";

    // Open the window.
    Xrm.Utility.openEntityForm("contact", null, parameters);

You can also use method to open an entity form instead of using openEntityForm.
Here is an example about it:

function OpenNewContact() {
    //Set the Parent Customer field value
    var extraqs = "parentcustomerid={G01F3F6D-896E-DF11-B414-00155DB1898A}";
    extraqs += "&parentcustomeridname=test";
    extraqs += "&parentcustomeridtype=account";
    //Set the Address Type to “Primary”.
    extraqs += "&address1_addresstypecode=3";
    //Set text in the Description field.
    extraqs += "&description=Default values for this record were set programatically.";
    //Set Do not allow E-mails to "Do Not Allow".
    extraqs += "&donotemail=1";
    //Set features for how the window will appear.
    var features = "location=no,menubar=no,status=no,toolbar=no";
    // Open the window."/main.aspx?etn=contact&pagetype=entityrecord&extraqs=" +
        encodeURIComponent(extraqs), "_blank", features, false);

Remarks: Using this function helps ensure that users are not prompted to log in again under certain circumstances.

For more information take a look at the MSDN page about this topic.


I hope you find this article useful.

See you 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *