Sample Code to use ReportExecution2005.asmx to generate PDF in CRM 2011.


Hi,

Just sharing a sample code that uses ReportExecution2005 web service of SSRS 2008, and generates pdf of one of the custom reports deployed in CRM.

Here we are also passing value to one of the report parameter.

<br />
 // Add web reference to following service<br />
 // http://server/reportserver/ReportExecution2005.asmx</p>
<p>ReportExecutionService rs = new ReportExecutionService();<br />
 rs.Credentials = System.Net.CredentialCache.DefaultCredentials;</p>
<p>// Render arguments<br />
 byte[] result = null;<br />
 // Get the report path from the report server<br />
 // http://reportserver/Reports/Pages/Folder.aspx?ViewMode=Detail</p>
<p>string reportPath = "/MyOrg_MSCRM/CustomReports/{837a8e7e-d949-e111-996a-00155d2a49c7}";<br />
 string format = "PDF";<br />
 string historyID = null;</p>
<p>string encoding;<br />
 string mimeType;<br />
 string extension;<br />
 Warning[] warnings = null;<br />
 string[] streamIDs = null;</p>
<p> ExecutionHeader execHeader = new ExecutionHeader();<br />
 rs.ExecutionHeaderValue = execHeader;<br />
 rs.LoadReport(reportPath, historyID);</p>
<p>// Set DataSource Credentials<br />
 // the user name is your userid and the password is the id of the organization<br />
 // get more info here<br />
 // http://ronaldlemmen.blogspot.com/2009/01/log-in-name-and-password-required-by.html<br />
 DataSourceCredentials datasetCredential = new DataSourceCredentials();<br />
 datasetCredential.DataSourceName = "DataSource1";<br />
 datasetCredential.UserName = "F45D4E20-44DE-E011-8A08-005056860004";<br />
 datasetCredential.Password = "D0E60C19-44DE-E011-8A08-005056860004";</p>
<p>// Set Report Parameter values<br />
 ParameterValue[] myPVArray = new ParameterValue[1];<br />
 ParameterValue myPV = new ParameterValue();<br />
 myPV.Name = "ReportParameter1";<br />
 myPV.Value = "True";<br />
 myPVArray[0] = myPV;</p>
<p>rs.SetExecutionParameters(myPVArray, "en-us");</p>
<p> DataSourceCredentials[] credentials = new DataSourceCredentials[1];<br />
 credentials[0] = datasetCredential;<br />
 rs.SetExecutionCredentials(credentials);</p>
<p>result = rs.Render(format, null, out extension, out encoding, out mimeType, out warnings, out streamIDs);</p>
<p>Response.Clear();<br />
 MemoryStream ms = new MemoryStream(result);<br />
 Response.ContentType = "application/pdf";<br />
 Response.AddHeader("content-disposition", "attachment;filename=labtest.pdf");<br />
 Response.Buffer = true;<br />
 ms.WriteTo(Response.OutputStream);<br />
 Response.End();<br />
 

Bye.

Advertisements

Cleared MB2-876 Extending Microsoft Dynamics CRM 2011 exam.


Hi,

Today i got a chance to take the extension exam and was able to clear it. There were 48 questions with passing marks of 700 and 145 minutes to answer them.

The question were mostly straightforward, very few questions were there which were scenario based. It was fairly easy exam when compared to other CRM 2011 exam.

Bye.

“The CRL type does not exist or you do not have permissions to access it” error while refreshing dataset in Query Designer (SSRS 2008)


I was getting the below error while trying to refresh the dataset in the query designer.

The workaround was to refresh the dataset from Report Data panel

Right click the dataset and select Dataset properties

Click on Refresh Fields button and Ok to close the dialog box.

Hope this helps.

Hiding and shrinking the width of the Column in SSRS 2008


Hi,

 We recently had a requirement wherein we were hiding few columns of our SSRS report dynamically based on value of a parameter.

The problem was that the hidden column although not visible was still consuming the space.

To solve this issue

  • Select Advanced Mode in the report Column Groups


  • Select the static column referring to the column we want to hide and set its Hidden property


The helpful post

http://blogs.msdn.com/b/robertbruckner/archive/2010/05/02/report-design-shrinking-hidden-static-columns.aspx

Bye.

Extending Microsoft Dynamics CRM 2011 (Exam MB2-876) exam has released.


Hi,

The extending exam for CRM 2011 has finally released. It was released on 29th Dec 2011, came to know about few days back.

http://www.microsoft.com/learning/en/us/exam.aspx?id=mb2-876&locale=en-us#tab1

Had been waiting for this exam for quite some time now. Would be taking it soon.

Bye.

Images not showing up in CRM 2011


Hi,

One of our clients was having issue wherein images in CRM 2011 were not appearing.

To resolve this issue we need to open Internet Explorer.

Then ToolsàInternet OptionsàAdvanced Tabà check Show Pictures option

Hope this helps.

Nishant Rana's Weblog

Everything related to Microsoft .NET Technology

Skip to content ↓