Creating a Popup screen using the Client Side API

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Creating a Popup screen using the Client Side API

  • Comments 2
  • Likes

I have written before about adding buttons to a page using the Client Side API in Sage CRM. See the articles

These articles show how easy it is to add buttons to the interface that can call new behaviour. But my articles made the two assumptions. The first is that when calling an ASP or a .NET Page from a button this would replace the existing page with the newly called page, so the button in other words navigates the user to that new page. The other assumption is that when calling an external web page you would want to pop up the page into a little window.

The missing piece is how to call an ASP page or .NET assembly in a popup window like below.

The following code was responsible for the button.

[code language="javascript"]
crm.ready(function () {
var buttonimage = '..\\Themes/img/color/buttons/about.gif';
var stringURL = crm.url("testpage.asp")+"&PopupWin=Y";
var buttonaction = {
'href': '#',
'index': 2,
click: function () {, 'newwindow', 'toolbar=0 , scrollbars=0, location=0, statusbar=0, menubar=0 , resizable=0, width=800, height=400, left = 340, top = 200'); }
crm.addButton(buttonimage, 'LPDataSourceTypes', 'reportChart', buttonaction);

The important element with the code is the way in which the URL has been built.

var stringURL = crm.url("testpage.asp")+"&PopupWin=Y";

The flag &PopupWin=Y tells Sage CRM not to draw the Main Menu and TopContent including the Tab Menu for the page. This makes the assumption that the page that you are calling is generating its code using the CRM.AddContent() and CRM.GetPage() methods. 

  • Jeff:  I would really like to have one of these popup windows for a WebApp that we created.  The WebApp is accessed off a button in Sage CRM.  I tried adding +"&PopupWin=Y" to my button but I don't get a pop up window.  The system just goes to the new page.  Therefore, I don't think I am putting this in the correct place.

    This is what I have tried...

    var strMyWebApp = CRM.Button('Web App','preparedatabase.gif', CRM.URL('WebApp/Default.aspx')+"&PopupWin=Y");



    var strMyWebApp = CRM.Button('Web App','preparedatabase.gif', CRM.URL('WebApp/Default.aspx'));


    Am I doing something wrong here?  Any assistance you could provide would be greatly appreciated!!

    Thank you!

  • Michele

    You need to check the help guide for the COM API Button method:

    It will look like

    var strMyWebApp = CRM.Button("Web App", "preparedatabase.gif", CRM.URL('WebApp/Default.aspx')+"&PopupWin=Y", "", "", "My Window");