RSS

CRM 2013 Open Entity Form in new Window by JavaScript

09 May

Introduction

During our customization in CRM, we need to open one Entity Form by JavaScript in a new Window.

Problem

By using Xrm.Utility.openEntityForm, it opens the record page in the same page or opens the record in a new Form.

Solution

To open the record in the new Window or to open in a new Dialog, we can use the following code

Note: Please give the Logical Name as Record Type is not taken in CRM 2013

function OpenRecords(Record_Id, Logical_Name_Of_Entity) {
    var reletivePath = "main.aspx?etn=" + Logical_Name_Of_Entity;
    reletivePath = reletivePath + "&pagetype=entityrecord&id=";

    var height = 1300; // Height of the Record Page.
    var width = 900; // Width of the Record Page.
    var windowName = "_blank";
    var serverUrl = Xrm.Page.context.getServerUrl();
    var nAgt = navigator.userAgent;

    if (serverUrl != null && serverUrl != "" 
                      && 
        Record_Id.replace("{", "").replace("}", "") != null)
    {
        serverUrl = serverUrl + reletivePath;
        serverUrl = serverUrl + Record_Id.replace("{", "").replace("}", "");
         
        if (nAgt.indexOf("Firefox") != -1) {
            window.open(serverUrl);
        } else {
            OpenStdWin(serverUrl, 
                       null, 
                       height, 
                       width, 
                       "titlebar=yes, resizable=yes");
        }
    }
}

By Sukant Shekhar
Senior Software Engineer @Team DynamicsCRM.
Mindfire Solutions

Advertisements
 

Tags: , , , , , , , , , , , , , , , , , ,

2 responses to “CRM 2013 Open Entity Form in new Window by JavaScript

  1. meenoo

    June 2, 2014 at 7:36 pm

    Does this work for all browsers as well?

     

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

 
%d bloggers like this: