MS CRM Reports can be accessed programmatically. But since MS CRM uses SQL Reporting Services, accessing reports is no CRM feature. Fortunately SRS exposes a webservice interface that you can use to do that. Further information can be found here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_prog_intro_1pia.asp
There are several possible use cases. E.g. if you want to trigger report creation and delivery by MS CRM workflow. For this you have to create a .NET assembly that will be used in your workflow. Next you have to add a reference to ReportServer/ReportService.asmx. You can figure out the rest looking at the following code snippet:
reportingserver.ReportingService rs=new reportingserver.ReportingService();
rs.Url="http://yourhoust/ReportServer/ReportService.asmx";
rs.Credentials=System.Net.CredentialCache.DefaultCredentials;
// or: new NetworkCredential("user", "pwd", "domainname");
byte[] result=null;
string reportPath="/yourorganizationname/reportname"; // adapt
string format="PDF"; // or XML, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, and HTMLOWC
string historyID=null;
string devInfo=@"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
ParameterValue[] parameters=null;
DataSourceCredentials[] credentials=null;
string showHideToggle=null;
string encoding;
string mimeType;
Warning[] warnings=null;
ParameterValue[] reportHistoryParameters=null;
string[] streamIDs=null;
SessionHeader sh=new SessionHeader();
rs.SessionHeaderValue=sh;
try
{
result=rs.Render(reportPath, format, historyID, devInfo, parameters, credentials,
showHideToggle, out encoding, out mimeType, out reportHistoryParameters, out warnings,
out streamIDs);
}
catch(SoapException e)
{
// ...
}
// Write the contents of the report to a PDF file and mail it
try
{
string filename=Path.Combine(Path.GetTempPath(), "report.pdf");
FileStream stream=File.Create(filename, result.Length);
stream.Write(result, 0, result.Length);
stream.Close();
MailMessage mm=new MailMessage();
mm.To="whoever@wants.it";
mm.From="reports@crm.com";
mm.Subject="Report";
mm.Body="... bla ... ";
MailAttachment att=new MailAttachment(filename);
mm.Attachments.Add(att);
SmtpMail.Send(mm);
}
catch ( Exception e )
{
// ...
}
Hf :-)