Recently in my current Project There is a requirement to generate a report on click of custom ribbon button, So I thought of writing this JavaScript code.
function OpenOrderReport() {
var rdlName = "ReportName.rdl"; // Replace with report name
var reportGuid = "00000000-0000-0000-0000-000000000000"; // Replace with desired report id
var entityType = "10000"; // Replace with entity type id.
var entityGuid = Xrm.Page.data.entity.getId();
var url = Xrm.Page.context.getClientUrl() + "/crmreports/viewer/viewer.aspx?action=run&context=records&helpID=" + rdlName + "&id={" + reportGuid + "}&records=" + entityGuid + "&recordstype=" + entityType;
window.open(url, null, 800, 600, true, false, null);
}
Just copy and paste this script in your web resource and call “OpenOrderReport” function on click of custom ribbon button and save & publish.