Monday 23 September 2013

Extracting the SSRS Report in PDF programmatically using Plugin or Wokflow in mscrm 2011

Extracting the Report in PDF programmatically.
Code snippet:
ReportGenerator rg = new ReportGenerator("http://crm/Reportserver/ReportExecution2005.asmx",
                new NetworkCredential("administrator", "Password", "contoso"));

            ParameterValue[] parameters = new ParameterValue[1];
            parameters[0] = new ParameterValue();
            parameters[0].Name = "P1";
            parameters[0].Value = string.Format("Select * From FilteredQuote Where QuoteId = '{0}'",
                context.PrimaryEntityId);

            byte[] reportresult = rg.Render("/contoso_mscrm/quote", FormatType.PDF, parameters);

            Entity attachment = new Entity("activitymimeattachment");
            attachment["objectid"] = Email.Get<EntityReference>(executionContext);
            attachment["objecttypecode"] = "email";
            attachment["filename"] =
            attachment["subject"] = "Quote.pdf";
            attachment["body"] = System.Convert.ToBase64String(reportresult);

Ref Links:




No comments:

Post a Comment