问题
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 !
回答1:
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:
- rdlName - rdl file name.
- reportGuid GUID of the report.
- entityGuid = Entity GUID wich you run report for.
- entityType = Entity Object Type Code.
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.
回答2:
After the RDL name the Guid should be RecordGuid not EntityGuid
来源:https://stackoverflow.com/questions/10583628/trigger-a-report-from-a-ribbon-button