Open report from custom ribbon button on entity form - CloudFronts

Open report from custom ribbon button on entity form

Posted On March 25, 2018 by Admin Posted in 

Introduction:

This blog explains how to open  report from custom ribbon button on entity form.

Steps to be followed:

1. Add custom button on entity form using Ribbon Workbench.

(If you don’t have ribbon workbench solution installed, you can install it from here. )

2. Once button is added on form, navigate to the Quote entity and run the report. Take note of the URL, it should look something like this. (I am doing it for quote entity)

URL: https://portals1.crm.dynamics.com/crmreports/viewer/viewer.aspx?action=run&context=records&helpID=Quote.rdl&id=%7b18c85c59-7d04-e711-80e6-00155db8652a%7d&records=%7bBD891D3F-C92C-E811-A831-000D3A37CC26%7d&recordstype=1084

Specifically note the items I’ve bolded, these are the report name, report unique identifier, and the entity type code of the main entity.

3. code to our new JavaScript web resource.

function OpenQuoteReport() {

debugger;

var rdlName = "Quote.rdl"; //Replace with your report name

var entityType = "1084"; //Replace

var entityGuid = Xrm.Page.data.entity.getId();

var reportGuid = "18C85C59-7D04-E711-80E6-00155DB8652A"; //Replace with your report guid

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);

}

4. Create Command i.e. add JavaScript web resource to the button using Ribbon Workbench.

5. Add command on button.

6. Publish.

7. Now go to Quote entity and click on the custom button which you have created, your report will get open.


Share Story :

Secured By miniOrange