Thursday, July 14, 2016

Open pure SSRS based reports in AX client

Normally you would create SSRS reports in AX using the inbuilt reporting frameworks, for example the report data provider (RDP) framework.

But in case you have pure SSRS based reports, created and hosted outside of AX and you want someway to integrate them in AX, there is no "out of the box" way around. But its not that difficult. What we can do is host the SSRS report's URL inside a web control in AX, as a SSRS report is essentially just a URL.

To begin with you need to determine your SSRS reports URL links. Some information on that.

The report URL is essentially made up of two parts.
1. The link to the SSRS report server where all reports are hosted.
For example, "http://abcServer/ReportServer"

So you could create a parameter say abcServerURL (table SRSServers) in System administration, report servers form to store this bit as it would be same for all your SSRS reports. Please note the SRSServers table is global, same value across all partitions and companies. If you dont want to have same value for all partitions you would want to store this value in a different table. If you have multiple partitions, multiple companies on the same AOS cluster, this property would be shared, which means same reports would be made available to all the users. Your BI consultant should implement a security layer to map the user ids with the exact partition/company data they should be exposed to. Otherwise you would expose other companies data to a user!

2. The part of the URL string that points to the exact report
For example, "/Pages/ReportViewer.aspx?%2fReports%2f+Sales+Report&rs:Command=Render"
We would create one form for each report and 'hardcode' this second bit of the URL inside each form.

Thus, the complete URL will be a concatenation of the two parts

So you might have 10 reports, all the 10 reports will have the same first part but a different second part, pointing to the exact report.

Next you need to design the form that hosts the web control. Create a form for each report. In design, add a managedHost control.

Finally in the init method of the form, we will "create" the URL and launch it.

 public void init()  
   System.Windows.Forms.WebBrowser  ssrsBrowser;  
   SRSServers                       sRSServers;  
   str                              url;  

   select firstonly abcServerURL from sRSServers;  
   if (!sRSServers.abcServerURL)  
     throw error ("Report server URL not setup");  

   url = sRSServers.abcServerURL + "/Pages/ReportViewer.aspx?%2fReports%2fSales+Report&rs:Command=Render";  
   ssrsBrowser= managedhost.control();  

Thats it. You have successfully managed to get pure SSRS power inside your AX. Cheers.

No comments:

Post a Comment