Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger a report from a ribbon button

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 !

like image 294
MademoiselleLenore Avatar asked May 14 '12 12:05

MademoiselleLenore


1 Answers

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:

  1. rdlName - rdl file name.
  2. reportGuid GUID of the report.
  3. entityGuid = Entity GUID wich you run report for.
  4. 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.

like image 188
Grigory Avatar answered Oct 05 '22 00:10

Grigory