web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Generate report to PDF using C#

(0) ShareShare
ReportReport
Posted on by 200

Hi All,

I have a webjob that auto send emails periodically, and this needs to attach a report as PDF.
This report is from an .rdl file imported to Dynamics 365 (online).

Most of the samples I saw is via javascript and on-premise, and have not found some example for D365 online via C#.
Question: Is it possible to auto generate it to PDF via C#?

Thank you all in advance.

Regards,
Chid

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi,

    I am not sure but found one link for you. You can try with this .Hope this helps, let me know.

    community.dynamics.com/.../how-to-send-ssrs-report-as-a-pdf-in-email-in-dynamics-crm-online

    Good Luck.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi, You can also check below msdn reference.

    msdn.microsoft.com/.../gg334240.aspx

  • OrchidC Profile Picture
    200 on at

    Hi Goutam,

    Thanks for the response, I have seen this sample and this is also in javascript.

    For the email attachment I have done it already but got stuck in the report generation inside my webjob.

    Thanks,

    Chid

  • Community Member Profile Picture
    on at

    Try using ZetPDF.com
    It worked for me perfectly!

    Best regards

    Fred Green

  • Shidin Haridas Profile Picture
    3,499 on at

    Hi Chid,

    Did you find a way to generate reports using c# for D365 online?

  • OrchidC Profile Picture
    200 on at

    Hi Shidin,

    Unfortunate no, what alternative I did that actually works perfectly now is I have a html template to PDF, so no .rdl involved.

    In that html template (which was stored in content snippet for easy editing if needs some updates) it mapped the data using fetchXML inside my webjob, once everything is in place it will then generate the base64 ready for creating an email attachment.

    For the mapping I use some keywords ready to replace:
    e.g. ##accountname## ---> once I get the account name in the webjob I just use Replace like the one below.
    _reportTemplate.Replace("##accountname##", AccountName);

    Regards,

    Chid

  • Shidin Haridas Profile Picture
    3,499 on at

    Hi Chid,

    Nice workaround.

    Cheers!

  • Suggested answer
    Shidin Haridas Profile Picture
    3,499 on at

    For anyone else landing up on this post:

    - There is no way to generate your reports in c# plugins for Online deployments, as you would not be having access to the Reporting Servers used.
    This is possible for OnPrem deployment models. But again, such plugins take a lot of execution time, which can easily cause CRM time-out errors, especially SSRS based reports, which retrieves a large data-set. 

    - You can generate the report through Javascript, and render the report into a HTML. Quite a piece of messy code, but this is possible, once you get the Report Session and the Control ID (https://community.dynamics.com/crm/f/117/t/253073)

    But, going down this route for complex reports is a pain-staking process.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hello,

    Question: Is it possible to auto-generate it to PDF via C#?

    Answer: According to me, It is not possible for online because we don't have access to the reporting server. I had tried plenty of time not found anything regarding this from past 3 years

    Hope you can achieve it!

  • Fusion Software Profile Picture
    20 on at

    Can i ask what solution you used to convert your HTML to PDF?

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans