SBX - Search With Button

SBX - Forum Post Title

Generate PDF file using JavaScript in Dynamics CRM

Microsoft Dynamics CRM Forum

BassTheNoise asked a question on 23 Apr 2019 2:02 PM

Question Status


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?



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.

BassTheNoise responded on 23 Apr 2019 2:34 PM

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

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


BassTheNoise responded on 23 Apr 2019 2:36 PM

The "CreateEmailAttachment" function is executed after the encodePdf function

BassTheNoise responded on 24 Apr 2019 1:51 PM

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. "

Pravin Pawar responded on 24 Apr 2019 11:28 PM
My Badges
Verified Answer
Pravin Pawar responded on 24 Apr 2019 11:28 PM
My Badges
Verified Answer

SBX - Two Col Forum

SBX - Migrated JS