Popup Window In Sage CRM Using .Net API

By | June 10, 2011

In Sage CRM, we usually use popup windows to show the information or to make instant data entry. In the custom ASP pages we make use of DOM objects to do so. To show popup window what we do is:

  1. We prepares an URL at server side (or at client side)
  2. Creates button and set the href for the same using window.open() method.

As we can see all the code that has been written at server side and client side is not secured at all. So here we can use Sage CRM .Net API code to popup a new window. This would make the coding very easier, less time consuming and would make sure that your code is secured.

Below is sample code which I have used in the .Net dll page to show custom entry page in popup window:

// Prepare new URL (action 432 is used for .Net dll pages) and add necessary parameters to url

sNewProjectURL = Url(“432”) + “&dotnetdll=Project.dll&dotnetfunc=RunCompanyProjectNew”;

//OR you can use below code

//string sNewProjectURL = UrlDotNet(“Project.dll “, “RunCompanyProjectNew”);

string sPopUpURL = UrlForPopUpWindow(sNewProjectURL, “NewProject”, 300, 300);

AddUrlButton(“New Project”, “new.gif”, sPopUpURL);

You can also make use of alternate code given below to popup the window:

string strNewURL = UrlDotNet(“CaseItem.dll “, ” RunCaseItemNew “);

string prviewurljs = “javascript:newwindow=window.open(‘” + strNewURL + “‘, ‘New Case Detail’, ‘toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,height=400,width=550’);if (window.focus){newwindow.focus();}”;

base.AddUrlButton(“New”, “new.gif”, prviewurljs);

Enjoy coding with .Net API J

If you find this content useful, please drop us an email at crm@greytrix.com.