A few months ago someone asked if if it was possible, using Power Automate, to get documents from Business Central, for example in pdf format and them email them or save them somewhere.

At that time I did a few tests and discovered it was simply not possible, using the standard apis. However, with the recent update, it is now very easy todo…


Let’s start with an example.

In Power Automate I’ll create a new flow, an Automated Cloud Flow:

And use the trigger: When a record is created:

Then I’ll use the salesInvoices api as an example:

When a salesinvoice is created, I want to get that record:

Now that we have the record of the invoice that was created, let’s get its document:

Now we have the document, in Pdf format.

The next step is to save it somewhere, or send it, for example via email:

Then test the flow, by creating a sales order and posting it:

And voila, email sent:

And if you don’t want to save the invoice document, but save it in OneDrive somewhere, you can do that too:

How cool is that!

To get the Pdf document I used this api:

Currently you can use it on:

  • salesInvoice
  • salesQuote
  • salesCreditMemo
  • purchaseInvoice

It’s a pity you can not use it on more document, like for example Purchase Orders, hopefully that might come in a next version…


16 Thoughts on “How Do I: Get Business Central (Pdf) Documents in Power Automate?

  1. Antoine on March 21, 2023 at 10:27 said:

    Hey Steven, thanks for sharing. It’s very interesting. What if I want to send the pdf to a specific department of a customer ?
    For example:
    – invoice are sent to invoice@company.com
    – shipment are sent to shipment@company.com
    – salesquote are sent to purchase@company.com

    Is that possible ?

  2. Paula on April 28, 2023 at 08:46 said:

    Hello Steven! Thank you for your post, it’s really useful. I’m trying to to the same for posted purchase invoice but it doesn’t work.
    My flow is:
    When a new record is created (posted purchase invoice from a purchase invoice, same API that in your example and PurchaseInvoice table) –> Get a record.
    But it doesn’t work but the source table for that API is Purch. Inv. Entity Aggregate, where posted record are also register… Any idea?

    Thank you in advance!!

    • The sourcetable(s) for the PurchaseInvoice API are Purchase Invoice Header and Line.

      If the table you want to use is not in these APIs:
      then you have to develop a custom API, and add the code to expose PDFDocument(s), which is not documented…

      • Paula on April 28, 2023 at 09:50 said:

        Hi Steven, thank you for your answer.
        I’ve a doubt, for your example it was also a posted invoice (sales in that case) but I suposse the process is similar. I was checking the API page ( 30042 – https://github.com/microsoft/ALAppExtensions/blob/main/Apps/W1/APIV2/app/src/pages/APIV2PurchaseInvoices.Page.al )for purchaseInvoice and the source table was Purch Inv Entity Aggregator so that’s why I though was the correct API to do it.
        Thank you

        • The aggregate table is used as the sourcetable in the page, but the data comes from PIH/PIL.

          You can try to use the page part:
          part(pdfDocument; “APIV2 – PDF Document”)
          Caption = ‘PDF Document’;
          Multiplicity = ZeroOrOne;
          EntityName = ‘pdfDocument’;
          EntitySetName = ‘pdfDocument’;
          SubPageLink = “Document Id” = Field(Id), “Document Type” = const(“Purchase Invoice”);
          in a custom API page.

          (I have not tried it myself yet.)

          • Paula on April 28, 2023 at 11:07 said:

            I’ve tried to do it but it doesn’t work anyway. Anycase, thank you for your time!!

  3. So many of the BC PA flows seem half done – the missing PurchaseOrder from this example, also PurchaseQuotes from the Modified Record trigger, PurchaseQuote-MakeOrder from the Action step.. the list goes on and on!

    • I understand and agree. They release new features, but only for a very limited set of APIs, and don’t provide any documentation on how to extend or create similar APIs yourself.

  4. Silvia on September 13, 2023 at 10:33 said:

    Hi, thanks for this! It’s great and a time saver! I have an issue I can’t find the way to solve: our language by default is spanish, and the invoice document is set to english if this language is selectect in the customer. But with this flow the pdf invoice is always in english, not spanish. Any thoughts that can help? Thanks a lot!

  5. Hi, I have the same issue with the language. I see this: To generate a document in the supported local language, you must specify Accept-Language in the Request header, for example Accept-Language: nl-NL for Dutch, but I don`t know how it works. https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_salesquote_pdfdocument

  6. Thank for such great content, although I am getting an error when I try to open the pdf file from outlook

    “Adobe Acrobat Reader could not open ‘Invoice because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn’t correctly decoded). ”

    I have extended the output of the flow to save to one drive and the pdf file opens from here without any error. From what I have manage to find to date it has something to do with Base64 and outlook requiring binary ?????

    • Seems like an issue in the outlook connector in Power Automate, because it works when you export to OneDrive. So you might want to ask an outlook-power-automate sme 😉
      How about you make the outlook connector pickup the attachment from the OneDrive folder/file?

  7. Carlo A Bergamini on January 3, 2024 at 20:30 said:

    It is mentioned it only works for Quote, Invoice and CM. Is there a way to get it to work for Orders and/or Shipments?

    • Yes it is mentioned, clearly.
      No, unfortunately, there’s no explanation anywhere how to add the same functionality to other documents.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post Navigation