Jscript Pop-up in Microsoft Dynamics CRM - Internet Explorer vs. Outlook

Visit Website View Our Posts

Occasionally when developing custom solutions in CRM, there will be a need to open a new window from Jscript. Typically the window.open function is used to accomplish this, but this is not always ideal in CRM.

Consider developing a custom solution in CRM where you need to open another CRM record in a new window. In the web interface of CRM the window.open function works fine, but what about the Outlook integration functionality? Well, in On-Premise this doesn’t pose a big issue because Internet Explorer will typically use your logged in account to authenticate with CRM. But what if you are not using On-Premise, or what if you have another set of logins specifically for CRM in your Active Directory environment (not sure why you would, but it could happen).

Outlook allows a user to cache their credentials to allow communication with the CRM environment without having to log in every time. However, if you open a new window using the standard Jscript window.open function, it will open your window in Internet Explorer not Outlook. In situations where you have to log in to reach CRM (i.e. not using On-Premise with your standard Active Directory account), this will require the user to enter their credentials before opening the correct page. This really disrupts the flow of any process, and is annoying and confusing to end users.

Luckily, Microsoft provided a function to handle this situation (although it is undocumented). There is an openStdWin function that is a part of the CRM Jscript implementation that will check to determine if the user is using Outlook or Internet Explorer, and open the new window in the appropriate format. The following code displays the way this functions:


function openNewWindow(url) {
var name = "newWindow";
var width = 800;
var height = 600;
var newWindowFeatures = "status=1";
var oldWindowFeatures = "width=800,height=600,status=1";
// Regular Jscript function to open a new window
//window.open(url, name, oldWindowFeatures);

// CRM function to open a new window
openStdWin(url, name, width, height, newWindowFeatures);
// CRM function to open a new window
// with default CRM parameters
//openStdWin(url, name);


One point to note, if you simply pass the url and name to the openStdWin function and leave off the width, height, and windowFeatures, the window will be opened with the same parameters that regular CRM windows are opened with. (i.e. same width and height as a standard CRM pop-up with no address bar, but with the status bar and resizable)

Now you don’t have to worry if the user is in Outlook or Internet Explorer, your pop-up window will open correctly. Enjoy!

Notice: openStdWin is an internal function of CRM and may change at any given point without notice.


Post by: Tyler Compton, Customer Effective

Show Buttons
Hide Buttons