Instantiation of the COM (eWare.CRM) object

1 minute read time.
The "eWare" or "CRM" COM Object can be instantiated in variety of ways.

1) ASP main interface application extensions
2) ASP Self Service pages
3) External Applications

1) ASP main interface application extensions

For application extensions of the main User Interface using ASP pages, you would use the eware.js/accpaccrm.js include file approach that Marc mentioned earlier.

A very simple ASP page build that way looks like:


 
">

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

eWare = Server.CreateObject(ClassName); 
eMsg = eWare.Init( 
Request.Querystring, 
Request.Form, 
Request.ServerVariables("HTTPS"), 
Request.ServerVariables("SERVER_NAME"), 
false, 
Request.ServerVariables("HTTP_USER_AGENT"), 
Accept); 


2) ASP Self Service pages

The second way of instantiating the COM object is in Self Service ASP pages. The code has to be different here because the Self Service use of the objects can't use the concept of a User session. It allows authentication of visitors and also anonymous access.

The include file for Self Service pages has code that instantiates the COM object like this:


eWare = Server.CreateObject("eWare.eWareSelfService"); 
eWare.Init( 
Request.Querystring, 
Request.Form, 
Request.Cookies("eware"),true); 


3) External Applications

Another way of instantiating the COM object is in external programs and window scripts. For example you may have a js file that the windows scheduler needs to run at fixed times.

In that type of file the code looks like:


var username = "Admin"; 
var password = ""; 
var eWare = new ActiveXObject("eWare.CRM"); 
eWare.FastLogon = 3; //this prevents the meta data from loading. 
eWare.Logon(username,password); 

////////////////// 
var ForReading = 1, ForWriting = 2, ForAppending = 8; 
var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0; 
var mySystemObject = new ActiveXObject("Scripting.FileSystemObject"); 
var myFile = mySystemObject.GetFile("e:/TEST.TXT"); 
//Assumes TEST.TXT exists 
var myFileTextStream = myFile.OpenAsTextStream(ForAppending, TristateUseDefault); 
//////////////////// 
//Retrieve Record 
var myRecord = eWare.FindRecord("person","pers_gender='Male'"); 
// 
while (!myRecord.eof) //eof checks for end of data and instantiates query 
{ 
myFileTextStream.WriteLine(myRecord.pers_firstname+" "+myRecord.pers_lastname); // eg. case_assigneduserid 
myRecord.NextRecord(); 
} 

myFileTextStream.Close();