[SOLVED] Report PDF Generation Issue in Dynamic 365 V9.0 using JavaScript

Introduction:
One of my clients had a requirement in Dynamics CRM v8.2 to simplify the report generation process. I added a button on the Quote entity which on click runs a report, captures its contents using JavaScript, converts it to PDF and attaches the PDF to an Email Record. 

Recently after the upgrade to Dynamics 365 v9.0 the pdf generated was corrupted. To tackle this i had to make some changes to the code. Lets quickly walk through it. 

Implementation:
Step 1:  Below shown is the code used in Dynamics 365 v8.2



Step 2: After the upgrade to Dynamics 35 v9.0 the below error message shown while debugging 



Error POST Request

On further research we found the URL that the url has been changed. To fix it, just change the URL in the code to the following

var pth = Xrm.Page.context.getClientUrl() + "/CRMReports/rsviewer/ReportViewer.aspx";

Hope this helped!

Comments

Popular posts from this blog

Run Workflow directly from a button in Dynamics 365 Customer Engagement V9.0

Create and Associate Records in a single operation using Xrm.WebAPI in D365 Customer Engagement

Use Audit Logs in Dynamics 365 : Actionable Audit