Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Generate PDF file using JavaScript in Dynamics CRM

Posted on by Microsoft Employee

I want to convert a ".rdl" report to PDF format using JavaScript and send it with an attachment, the PDF file is attached to the email, but when I send it and open it, the PDF file shows an opening error.

Is there any consideration I should have?

*This post is locked for comments

  • Verified answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Generate PDF file using JavaScript in Dynamics CRM

    Hello,

    Please refer following url for reference:

    jsfiddle.net/.../0816jdfq

    ankit.inkeysolutions.com/.../dynamics-crm-2011-creating-e-mail.html

    community.dynamics.com/.../205829

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Generate PDF file using JavaScript in Dynamics CRM

    I have also detected that the pdf file that I receive in the email marks the following error:

    " Error.
    Try this action again. If the problem persists, consult the Microsoft Dynamics 365 Community for solutions or contact your organization's Microsoft Dynamics 365 administrator. Ultimately, you can contact Microsoft Technical Support. "


  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Generate PDF file using JavaScript in Dynamics CRM

    The "CreateEmailAttachment" function is executed after the encodePdf function

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Generate PDF file using JavaScript in Dynamics CRM

    In the email it appears attached, the size is 357 bytes, mail reaches me of 679 bytes.

    Captura01.JPG

    And this is the code that I use to attach the file:

    function CreateEmailAttachment(bdy,emailuno) {
    
    
        var activitymimeattachment = Object();
        activitymimeattachment.ObjectId = Object();
        activitymimeattachment.ObjectId.LogicalName = "email";
        activitymimeattachment.ObjectId.Id = emailuno;
        activitymimeattachment.ObjectTypeCode = "email";
        activitymimeattachment.Subject = "File Attachment";
        activitymimeattachment.Body = bdy;
        activitymimeattachment.FileName = "Enviar Oferta.pdf";
        activitymimeattachment.MimeType = "application/pdf";

    }

  • Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Generate PDF file using JavaScript in Dynamics CRM

    Hi

    It might help if you could add some screenshots and possibly the bit of code that downloads the PDF and then attaches to the email.

    Normally converting to PDF and attaching it to email is done using Server Side Code either using a plugin or CWA.

    If you are doing both of these using JS, please make sure the file size is as expected and also make sure the correct mimetype is set

    The following link has a C# example but the approach is still the same if you are converting an SSRS report to PDF.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans