Error when calling INIT method through Self service

By | September 4, 2010

When we are using CRM Self Service, the basic methodology that we need to follow is to first initialize the Self Service object and then do the operations with database as per the need. The INIT methods help in initializing the object and then operate on CRM database. This fundamental works on the principal of session and cookies. This method is called as shown below in “ewaress.js” file which is included in all Self service pages.

CRM = Server.CreateObject(“eWare.eWareSelfService”);

Well, this process works quite efficiently, however I came across an interesting fact some days ago while working on a third party application. We have implemented a Self service portal for one of our clients. The portal works on third party access i.e. The login page from clients website takes the credentials and then through proxy server connects to CRM self service page for authentication. The operation was carried out in an Iframe on web page and the application was built and deployed on CRM server. We did some testing being on server itself and everything was working fine.

Then we decided to give it a try from outside their network i.e. from our end we opened the website. We accessed the login window, entered credentials and clicked Login button. Wholla!! Nothing happened and the same login page is being displayed. There were no chances of credentials being wrong as they all were handled to display an error message on page. So I decided to open an Iframe setting its height and width. What I found in iframe is an error stating “Init not called.”. This error was thrown on the line where I was using CRM.FindRecord. This pointed me to conclusion that there is a possibility that Self service object is not initialized. So I decided to check return type on CRM.init function above as given below.

Response.Write (typeof (CRM.init (Request.Querystring, Request.Form, Request.Cookies (“CRM”))))

The return type of the method was String. Then I decided to check what is being returned in string.

Var InitOut = typeof(CRM.init(Request.Querystring,Request.Form,Request.Cookies(“CRM”)))

Here I got an error saying “Unexpected Event”.

Checked the log file for this and found that the error was occurring when an entry was made in User Agent table while creating session. The error was SQL error in inserting out of range data in field usra_useragent. The client browser information is pushed in this field when session is created. The field length was set to 200 and the data being pushed was of length 260. I changed the maximum allowable length of this field to 400 which resolved my problem. Quite strange that this value is directly proportional to browser version from which we are opening the website and authenticating self service

as a resultant of which an information being sent may be of any length that we can’t determine. Just set it to appropriate value you can think of and you are done.

If you find this content useful, please feel free to drop us an email at