Launch a Report in Ribbon Button click
First create a Report in ssrs or report area in crm 2011
if you created in SSRS. deploy in crm.
Get the GUID of the report
how to get guid:
open the report and press F11.
then write the below code in javascript:
// JScript source code
function openreport(id) {
var errorMessage = "Context is not available.";
var context;
if (typeof GetGlobalContext != "undefined") {
context = GetGlobalContext();
}
else {
if (typeof Xrm != "undefined") {
context = Xrm.Page.context;
}
else {
alert(errorMessage);
return;
}
}
var str = id;
// alert(id);
// var strId = str.replace("{", "");
//alert("hi");
var orgUrl = context.getServerUrl();
var currEntityObjTypeCode= Xrm.Page.context.getQueryStringParameters().etc
//alert(currEntityObjTypeCode);
//alert(orgUrl);
var reportUrl = orgUrl + "/crmreports/viewer/viewer.aspx?action=run&context=records&helpID=OrderAcknowledgement.rdl&id=%7b20a4c6e9-8f6f-e211-957a-
00155d000b45%7d&records=" + encodeURIComponent( id ) +"&recordstype="+currEntityObjTypeCode;
//alert(reportUrl);
window.open(reportUrl);//, "_blank", "width=900px,height=600px,resizable=1");
//return reportUrl;
}
First create a Report in ssrs or report area in crm 2011
if you created in SSRS. deploy in crm.
Get the GUID of the report
how to get guid:
open the report and press F11.
then write the below code in javascript:
// JScript source code
function openreport(id) {
var errorMessage = "Context is not available.";
var context;
if (typeof GetGlobalContext != "undefined") {
context = GetGlobalContext();
}
else {
if (typeof Xrm != "undefined") {
context = Xrm.Page.context;
}
else {
alert(errorMessage);
return;
}
}
var str = id;
// alert(id);
// var strId = str.replace("{", "");
//alert("hi");
var orgUrl = context.getServerUrl();
var currEntityObjTypeCode= Xrm.Page.context.getQueryStringParameters().etc
//alert(currEntityObjTypeCode);
//alert(orgUrl);
var reportUrl = orgUrl + "/crmreports/viewer/viewer.aspx?action=run&context=records&helpID=OrderAcknowledgement.rdl&id=%7b20a4c6e9-8f6f-e211-957a-
00155d000b45%7d&records=" + encodeURIComponent( id ) +"&recordstype="+currEntityObjTypeCode;
//alert(reportUrl);
window.open(reportUrl);//, "_blank", "width=900px,height=600px,resizable=1");
//return reportUrl;
}
Change in code :
chage the id parameter with your Report guid.
create a web resource and put this code as jscript.
No comments:
Post a Comment