Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Highlighted
Nickel Elite Contributor
Posts: 86
Registered: ‎10-21-2009

Calling Crystal Report On Button Click

[ Edited ]

 

Hi All,

 

We are currently working on a migration project from SLX 7.5.4. LAN to WEB.

 

As per requirement we need to call a Crystal Report On a Button Click after validating existance of  values in some fields. This crystal report is working fine in LAN environment. But we are finding it bit difficult to get this thing replicated in Web. As per my understanding the problems are,

 

i. This report is getting fetched from a view.

ii. I don't have any MainView for this DataBase view.

 

But I am able to enable that view in Architect and manage to create entity for the same.

 

Still not able to get things going.

 

Any hwlp will be highly appreciated.

 

Thanks in advance

Malay Mukherjee

 

Note : Sales Logix Version-7.5.4

Database: SQL Server 2008

Highlighted
Bronze Super Contributor
Posts: 152
Registered: ‎02-01-2011

Re: Calling Crystal Report On Button Click

C# snippet example:

 

string script = @"
function ShowYourReportName(){
var contextSvc=Sage.Services.getService('ClientEntityContext');
var context=contextSvc.getContext();
var id=context.EntityId;
var strReportId=GetReportId('Account:YourReportName');
PopulateGlobals(strReportId,'ACCOUNT','');
GLOBAL_REPORTING_WSQL=""ACCOUNTID='""+id;
GLOBAL_REPORTING_SQLQRY=""SELECT ACCOUNTID, ACCOUNT FROM YOURVIEW"";
var url='ShowReport.aspx';
window.open(url,'ShowReportViewer','location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=800,height=630');
}
";
ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), "YourReportName", script, true);

 Then call the JS function ShowYourReportName() in the OnClientClick of your button. You can add validation to the above for client-side, or disable the button server side.

Andy Freeman
TrellisPoint, LLC
Highlighted
Nickel Elite Contributor
Posts: 86
Registered: ‎10-21-2009

Re: Calling Crystal Report On Button Click

Hi greensweater,

 

Still facing problem in fetching reports for custom entity. Though the report is working from Report Manager screen, recieving following error while openeing the report from button.

 

Failed to retrieve data from the database. Failed to retrieve data from the database. Error in File ...

 

My Code is as under,

 

string script = @"
function ShowYourReportName(){
var contextSvc=Sage.Services.getService('ClientEntityContext');
var context=contextSvc.getContext();
var id=context.EntityId;
var strReportId=GetReportId('BusinessOwnerSmiley Tongueoints Statement');
PopulateGlobals(strReportId,'BusinessOwner','');
GLOBAL_REPORTING_WSQL=""Business_Owner='""+id;
GLOBAL_REPORTING_SQLQRY=""SELECT POINTS.TRAN_DATE, C_ACC_ARABIC_NAME.ARABIC_NAME, POINTS.TRANTYPE, POINTS.ALLOCATED, POINTS.REDEMED, BUSINESS_OWNER.FIRST_NAME, BUSINESS_OWNER.LAST_NAME,  LOYALTY_MEMBERSHIP.LOYALTY_PROGRAM_ID, LOYALTY_MEMBERSHIP.DATE_ENROLLED,  LOYALTY_MEMBERSHIP.STATUS, ACCOUNT.DIVISION, ACCOUNT.ACCOUNT,  C_POINT_SETTING_HEADER.START_DATE, C_POINT_SETTING_HEADER.END_DATE,  C_25_ACCOUNT.CODE, C_25_ACCOUNT.NAME FROM   ((((( sysdba.BUSINESS_OWNER BUSINESS_OWNER INNER JOIN sysdba.POINTS POINTS  ON BUSINESS_OWNER.BUSINESS_OWNERID=POINTS.BUSINESS_OWNERID)  INNER JOIN sysdba.LOYALTY_MEMBERSHIP LOYALTY_MEMBERSHIP  ON BUSINESS_OWNER.BUSINESS_OWNERID=LOYALTY_MEMBERSHIP.BUSINESS_OWNERID)  LEFT OUTER JOIN sysdba.ACCOUNT ACCOUNT  ON POINTS.ACCOUNTID=ACCOUNT.ACCOUNTID)  LEFT OUTER JOIN sysdba.C_ACC_ARABIC_NAME C_ACC_ARABIC_NAME  ON POINTS.ACCOUNTID=C_ACC_ARABIC_NAME.ACCOUNTID)  LEFT OUTER JOIN sysdba.C_POINT_SETTING_HEADER C_POINT_SETTING_HEADER  ON POINTS.POINT_ORG_ID=C_POINT_SETTING_HEADER.C_POINT_SETTING_HEADERID)  LEFT OUTER JOIN sysdba.C_25_ACCOUNT C_25_ACCOUNT  ON POINTS.C_25_ACCOUNTID=C_25_ACCOUNT.C_25_ACCOUNTID"";
var url='ShowReport.aspx';
window.open(url,'ShowReportViewer','location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=800,height=630');
}
";
 ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), "PointStatement", script, true);    

 btnPrint.OnClientClick = "javascript:ShowYourReportName()";

 

 

 

Please suggest...

 

Thanks in Advance

Malay Mukherjee

Highlighted
Bronze Super Contributor
Posts: 152
Registered: ‎02-01-2011

Re: Calling Crystal Report On Button Click

Looks like your WSQL variable is at fault, the entity ID is alphanumeric and should be in single quotes.

 

GLOBAL_REPORTING_WSQL=""Business_Owner = ''"" + id + ""'"";

 

The double-quotes are doubled because they're in the C# heredoc syntax, it's kind of hard to read.

 

""Business_Owner = '"" + id + ""'""

Andy Freeman
TrellisPoint, LLC
Highlighted
Nickel Elite Contributor
Posts: 86
Registered: ‎10-21-2009

Re: Calling Crystal Report On Button Click

Hi greensweater,

 

Thanks for your response.

 

I have applied the modification suggested by you, but still facing same problem.

 

Please let me know if you need some more details.

 

Thanks and Regards

Malay Mukherjee