Using COM ASP pages in the Reports area in Sage CRM 7.1 and earlier

Hints, Tips and Tricks

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

Using COM ASP pages in the Reports area in Sage CRM 7.1 and earlier

  • Comments 3
  • Likes
This article has been updated to further describe the technique used and to ensure the code conforms to the convention introduced in Sage CRM 6.2.
Along time ago in previous versions of Sage CRM (when it was called eWare) reports used to consist of actual text files stored in the folders underneath the reports folder.


... \Program Files\Sage\CRM\\WWWRoot\Reports

In recent versions the only documented use of these folders is to allow Crystal Reports rpt files to be dropped into the system. (See page 38-1 of the Sage CRM 6.0 System Administrator Guide)

But a nice side effect of the history is that if you drop an ASP page into the same folders -for example under the General or Sales folder then that file will be automatically listed within Sage CRM as an report available to be run.

Note: Only files with the extension ASP (or rpt) will be listed. Files with other extensions such as doc or aspx will be ignored. It is not expected that Sage CRM .NET Application Extensions will be able to be called under the reports area.
The fact that we can have ASP pages listed within the reports area means that we can now potentially link to any reporting tool that has a web interface. It is important to to note that the initial URL to the file is in the form:


which redirects to


The URL to the file includes the SID (Session ID) which means that we could therefore instantiate the eWare COM object and correctly maintain a user session. This allows use to use CRM blocks, objects and methods as well as redirecting to any other web based reporting tools. Our ASP "report" therefore could be a mix of a CRM list block with various graphic and chart blocks or redirect to an web based reporting tool like Microsoft SQL Server Reporting Services. 

To use the eWare object then I would have to include a reference to the standard include files.

I dropped in an ASP page into the General folder under the Reports area. I wanted to use the standard include files so I made sure that my ASP page included the reference to

When I came to run the file I got a nasty error.

Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid class string
/CRMdemo/custompages/eware.js, line 41

Note:  If you have used the accpaccrm.js and accpaccrmnolang.js include files then the error will occur at line 38 of the accpaccrmnolang.js file.
The ability to call ASP pages from within the Reports folder has never been an official feature, so it is not surprising that an occasional wrinkle should appear within it.

In my case Line 41 contains

eWare = Server.CreateObject(ClassName);

The ClassName variable is produced in the lines preceding this by the code

var sInstallName = getInstallName(Request.ServerVariables("URL"));
var ClassName = "eWare."+sInstallName;

In turn, the getInstallName function is contained at the end of the eware.js include file (also in the accpaccrmnolang.js) and is a very useful helper function.

function getInstallName(sPath) {
//Parse the install name out of the path
var Path = new String(sPath);
var InstallName = '';
var iEndChar=0;iStartChar=0;

Path = Path.toLowerCase();
iEndChar = Path.indexOf('/custompages');
if (iEndChar != -1) {
//find the first '/' before this
iStartChar = Path.substr(0,iEndChar).lastIndexOf('/');
InstallName = Path.substring(iStartChar,iEndChar);
return InstallName;


As we can see from the above code the URL is passed to the getInstallName function. The problem occurs because the function expects to be used in the context of the custompages folder and not the reports folder. The eWare.js file (and the accpaccrmnolang.js file) used to have the reference to the class name in the Server.CreateObject() method hardcoded, but to solve other problems this reference was made dynamic many versions previously. This in turn creates a problem for the use of the include files in the Reports area.

The URL of the called ASP page looks like this:


This in turn passes the following into the function parameter sPath:


So what can we do?

The easiest thing to do is copy the include files that you are using directly into the Reports folder and then hardcode the path correctly. The files need to be copied into the reports area so that we do not end up breaking our other ASP pages. This is a quick and 'dirty' solution. If your CRM install is called 'CRMdemo' then the line in the include file will need to read.

CRM = eWare = Server.CreateObject("eWare.CRMdemo");

Code Used in Above Example

<!-- #include file ="eware.js"-->
var intRecordId = CRM.GetContextInfo("user","user_userid");

var UserSearchBoxBlock = CRM.GetBlock("NewUserPreScreen");
UserSearchBoxBlock.ArgObj = CRM.FindRecord("user","user_userid="+intRecordId);
UserSearchBoxBlock.Title = CRM.GetTrans("Tabnames","user");

var opportunitylistBlock = CRM.GetBlock("opportunitylist");
opportunitylistBlock.ArgObj = "oppo_assigneduserid ="+intRecordId;

var graphicBlock=CRM.GetBlock("chart");
labelx="Assigned User";
labely="No Opportunities";
SQLText="select count(oppo_opportunityid) as oppo_count, user_firstname + ''+user_lastname as user_fullname from opportunity, users where user_userid = oppo_assigneduserid group by user_firstname, user_lastname;";

var myBlockContainer = CRM.GetBlock("Container");
var strPrintButton = CRM.Button("print", "print.gif", "javascript:window.print();");
var strCloseButton = CRM.Button("close", "close.gif", "javascript:window.close();");

with (myBlockContainer)
DisplayButton(Button_Default) = false;



  • I can tell that there is a lot of good information in this article but I'm having trouble putting the big picture together.  Assume that I have a custom entity using COM asp pages and I want to call one of these reports.  How do I inturpret your URL and redirect statements above to create a URL for a custom button on my page?

    I understand copying the include file(s) to the the reports directory but the include file statement (eWare = ...) above is not shown in example code.  Is it in your asp file or are you modifying the include file code?

    Would you recommend this approach to create a 'Summary Report' for custom entities?

  • Is this supposed to still work with version 7.0 ?

  • I've just tried this in Sage CRM v7.1sp1 and it still works.  I had to make sure I copied the sagecrm.js and sagecrmnolang.js files into the "reports" folder.  The actual ASP page was in the "general" folder.  I referenced the include file in my ASP page using

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

    And I had hard coded the line in the sagecrmnolang.js to read

    CRM = eWare = Server.CreateObject("eWare.CRM");

    But it did work.