I have several custom reports and I would like to be able to add buttons to the ribbon that trigger them.
Is it possible? And if so, any examples would be great !
Thanks in advance !
To run a report from a ribbon button you need to create a js file with a function you'll be calling from your button.
You need 4 things:
Here is the example.
function printOutOnClick() {
// This function generates a Print out
var rdlName = "SomeReport.rdl";
var reportGuid = "9A984A27-34E5-E011-B68F-005056AC478A";
var entityGuid = Xrm.Page.data.entity.getId();//Here I am getting Entity GUID it from it's form
var entityType = "4214";
var link = serverUrl + "/" + organizationName + "/crmreports/viewer/viewer.aspx?action=run&context=records&helpID=" + rdlName + "&id={" + reportGuid + "}&records=" + entityGuid + "&recordstype=" + entityType;
openStdDlg(link, null, 800, 600, true, false, null);
}
openStdDlg() is the wrapper around window.open() MS Dynamics CRM uses it itself, so do I.
To add it to a ribbon button you need to do like in this post How to start a Dialog from Application Ribbon (CRM 2011) except you need to call report instead a dialog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With