How to Build Buttons that call the Email Editor using the COM ASP API

Hints, Tips and Tricks

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

How to Build Buttons that call the Email Editor using the COM ASP API

  • Comments 14
  • Likes
This has article has been corrected and the code reformatted 17th October 2011.
 
I have written before about building buttons that call the inbuilt system actions. The action code for the internal email editor is 1500.

We can set up a new SendEmail button on a custom page that will either display the editor in
  • Full Screen
  • Split Screen or in a
  • Popup Window

The code below shows how to create the buttons of each type and add them to a block.


//Code to call a Full Screen Email Editor

var strFullScreenEmailButton = eWare.Button("fullscreen","sendemail.gif", eWare.Url(1500)+"&key-1=1&newbtn=t");

//Note Key-1 contains the integer that represents the entity previously in context e.g. 1=Company, 2=Person. See other articles about the Key Values to learn more.
//Code to call a Split Screen Email Editor
var strScript = "javascript: x= parent.frames['EWARE_HIDDEN'].location='"+eWare.URL(1500)+"&newbtn=t&Frame=email'; parent.SECONDSET.rows='70,*,*,0,0'; parent.SECONDSET.frameSpacing=1; parent.EWARE_HIDDEN.noResize=false; void(x)"
var strSplitScreenEmailButton = eWare.Button("splitscreen","sendemail.gif", strScript);

//Code to call the Email Editor in a PopUp window.
var strScript2 = "javascript: x = window.open('"+eWare.URL(1500)+"&newbtn=t&Frame=popup','email','scrollbars=yes,resizable=yes,width=920,height=600'); void (x)";
var strPopUpEmailButton = eWare.Button("popupscreen","sendemail.gif", strScript2);

//Add Buttons to Block
var myBlock = eWare.GetBlock("myscreen");
myBlock.AddButton(strFullScreenEmailButton);
myBlock.AddButton(strSplitScreenEmailButton);
myBlock.AddButton(strPopUpEmailButton);

The button code here can be adapted for use in the .NET API.
 

Comments
  • I am trying to display the new invoice line item screen within the invoice page as similar to the order line items screen. I am using the following code to achieve it.

    var strScript = "javascript: x= parent.frames['EWARE_HIDDEN'].location='"+eWare.URL("NewLineItem.asp?invo_invoiceId="+thisInvoiceNumber+"&invo_currency="+thisCurrency)+"'; parent.SECONDSET.rows='30,*,*,0,0'; parent.SECONDSET.frameSpacing=1; parent.EWARE_HIDDEAN.noResize=false; void(x)";

    container.AddButton(CRM.Button("New Line Item","",strScript));

    When the New line Item button is clicked, new invoice line item screen is displayed within the invoice screen but it is over written by the invoice screen suddenly.

    Could you please suggest me a solution for the above problem?

  • Kumaran

    I would experiment with calling a static page.  So that instead of calling NewLineItem.asp, call a simple html file.  You want to see whether the change is taking place because of the NewLineItem.asp page doing something or whether the change happens because of the parent ASP page.

  • If I call a simple html page, it is displaying the split page correctly.But if I call a asp page that does nothing,It gives the same problem.

  • Then you will need to look at the code that is used in the ASP page.  I would start with a blank ASP page and add the lines back in one at a time to see at which point the page 'misbehaves'.

  • I have tested calling an empty asp page.It gives the same problem.But If I take out Response.Write(CRM.GetPage()) from the asp code,the error doesn't appear.

  • Comment out the code

    CRM.AddContent(myblock.Execute());

    Response.Write(CRM.GetPage());

    and

    try

    Response.Write(myBlock.Execute());

  • Yes it works but it gives me the white colour page with the fields.The format of the page is different from the normal CRM page.

  • Then change your ASP page to follow this format.

    Note:  The Response.Write(Head) line

    <!-- #include file ="sagecrm.js"-->

    <%

    Response.Write(Head);

    ///

    // Your code goes here.

    ///

    Response.Write(myBlock.Execute(Arg));

    %>

  • Thanks a lot. It works fine now.

  • How do I link the hyperlink of the product name in the invoice line item grid to display Line item screen in the frame as in Order and Quote screens?

  • Can you post this in the forums please.

  • I am not able to refresh the parent page once line item is created and the added line items are not reflected in the line item grid in the parent page.But while refreshing the grid(clicking next page button of the grid),it shows me the added line item record.

  • Can you please tell the procedure to post in the forums ?

  • You can find the forums here:

    community.sagecrm.com/.../default.aspx

    If you don't have rights to post into the partner forums, then contact sagecrmteam@sage.com