Hi Krishna,
This is not so simple, but the logic would be as follows.
First you need to create an SSRS report, that will take a Case Id parameter (better you prefiltering in this case).
The I would use JS code to do the following:
1. Create an Email Activity using Web Api (or call action), and get the Email Id back from the process.
2. Get the Reporting Session by calling the following function (attached function based on account):
var reportingSession = getReportingSession(accountId);
function getReportingSession(accountId) {
var strParameterXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='account'><all-attributes /><filter type='and'><condition attribute='accountid' operator='eq' value='" + accountId + "' /> </filter></entity></fetch>";
var reportName = "AccountReport.rdl";
var reportGuid = "DC06A823-C265-D311-6144-1252A24B35B1";
var path = context.getClientUrl() + "/CRMReports/rsviewer/QuirksReportViewer.aspx";
var req = new XMLHttpRequest();
req.open("POST", pth, false);
req.setRequestHeader("Accept", "*/*");
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.send("id=%7B" + reportGuid + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName=" + reportName + "&isScheduledReport=false&p:CRM_FilteredAccount=" + strParameterXML);
var x = req.responseText.lastIndexOf("ReportSession=");
var y = req.responseText.lastIndexOf("ControlID=");
var rc = new Array();
rc[0] = req.responseText.substr(x + 14, 24);
rc[1] = req.responseText.substr(x + 10, 32);
return rc;
};
3. Create the attachment object, and call the function to create the attachment:
var attachment = Object();
attachment["subject"] = "File Attachment";
attachment["filename"] = "MyFile.pdf";
attachment["mimetype"] = "application/pdf";
attachment["objectid_email@odata.bind"] = "/emails(" + activityId + ")";
attachment["objecttypecode"] = "email";
attachment["body"] = binaryPDFContent;
createEmailAttachment(attachment)
function createEmailAttachment(attachment) {
return $.ajax({
method: "POST",
contentType: "application/json; charset=utf-8",
url: clientUrl + "/api/data/v8.2/activitymimeattachments",
data: JSON.stringify(attachment),
dataType: "json",
beforeSend: function (xhr) {
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("OData-Version", "4.0");
xhr.setRequestHeader("OData-MaxVersion", "4.0");
}
});
};
The code and logic might have to be tweaked a little for your needs, but hopefully this will help you enough to get you started.
Hope this helps.