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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Converting PDF file into base64String in D365 Finance and operations

(0) ShareShare
ReportReport
Posted on by 505

Hi All,

We are using Standard Business Event of Purchase Order Workflow for sending the Email notification through Microsoft Flow and get it approved through email.

Now I have to do customization for adding an attachment of report in WF notification. The idea is to add new field of type String in Business Events and then transfering the PDF file through Business Events to Microsoft Flow. For this

1) I have to convert(Encode) PDF file into base64String in D365 Finops

2)transfering to Flow through Business Events

3) Decoding the file from base64String to PDF in Microsoft Flow and send as attachment in Email Notification.

Could you please let me know, above solution is feasible or not and Code to convert PDF to Base64 in D365 finOps?

I have the same question (0)
  • Blue Wang Profile Picture
    on at

    Hi Ishu,

    You can convert PDF to Base64 through this code:

    System.Byte[] pdfDocBuffer;
    System.IO.FileInfo fi_pdfDoc;
    System.IO.FileStream fs;
    str Content;
    new InteropPermission(InteropKind::ClrInterop).assert();
    fi_pdfDoc = new System.IO.FileInfo(@'C:/test.pdf');
    pdfDocBuffer= new System.Byte[int642int(fi_pdfDoc.get_Length())]();
    fs= new System.IO.FileStream(fi_pdfDoc.get_FullName(), System.IO.FileMode::Open, System.IO.FileAccess::Read);
    fs.Read(pdfDocBuffer, 0, pdfDocBuffer.get_Length());
    Content = System.Convert::ToBase64String(pdfDocBuffer, 0, pdfDocBuffer.get_Length());
    CodeAccessPermission::revertAssert();

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    I think that including hundreds of kilobytes of data in the business event goes against the idea of business events. They are supposed to be lightweight and provide minimal information, not be used for data integration purposes.

    I would not recommend implementing a solution that goes against Microsoft's guidance, even if it's technically possible.

    docs.microsoft.com/.../business-events-dev-doc

  • Ishu.caddengg@hotmail.com Profile Picture
    505 on at

    Thanks Blue Wang and Nikalaos

    @Nikalaos - The Size of the PDF File will be within 600KB. I dont think this will be an issue till the file size is small/within this range. Onthe other hand data transfer will take place in JSON file format which is again additional benefit.

    Do you have any other idea of handling this requirement?

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    600kb is a lot for a business event, which are normally a few kb.

    I would recommend sending only key info in business event and fetching the PDF via custom service or data entity. If you read the MS article, that seems like the recommended way.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans