Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Dynamics 365 BC - Receive and Invoice from PO using API

(0) ShareShare
ReportReport
Posted on by 5

We're using Dynamics 365 BC on Cloud, and successfully tested the API v2.0 to query, filter, update purchase orders / lines. We now want to "Receive and Invoice" from a PO using API, the same way we do in UI:

  • Define a supplier invoice Id at PO header level
  • Set receiveQuantity / invoiceQuantity at PO lines level
  • Select "Receive and Invoice"
    • PO updated with adjusted receivedQuantity and invoicedQuantity
    • Supplier invoice created

It seems that this kind of basic action needs custom extension ? Is that correct ? How to do that ? Could somebody share an example ?

Thanks !

  • Babin Profile Picture
    Babin 2,947 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    Hi Vincent, still waiting.. are you planning to share your results and examples any time soon..

  • Vincent D Profile Picture
    Vincent D 5 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    Hi,

    I'm currently out of the office, I'll share results and examples here soon.

    Vincent

  • Babin Profile Picture
    Babin 2,947 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    Hi Vincent, I am exactly trying to do the same thing you completed.

    I know how to create PO using API. Now we need to create a PO Invoice in 2 ways:

    • "Receive and Invoice" totally or partially the PO

    • "Invoice only" totally or partially- if receipt already exists

    I would really appreciate if you can share how you did it, what method we need to use and if you can provide some examples.

    Thanks!!

  • Vincent D Profile Picture
    Vincent D 5 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    Yes but it never return values:

    Call example: {{baseUrl}}/companies({{companyId}})/attachments?$filter=parentId eq bf4eb7ea-d558-ec11-bb7c-000d3a2b9aee and parentType eq 'Purchase Invoice'

    Always returns:

    {

       "@odata.context": "api.businesscentral.dynamics.com/.../$metadata

       "value": []

    }

    but this Purchase Invoice is valid and has attachment (not found in attachment table but in 'Document Attachment' table)

    And no idea on how to get 'Attachment Notes'

    ...

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 995 Super User 2024 Season 1 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    Have you looked at the attachement API ?

    docs.microsoft.com/.../dynamics_attachment

  • Vincent D Profile Picture
    Vincent D 5 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    Hi,

    It seems that the Purchase invoice attachments are stored in 'Document Attachment' table but we did not find any API to manipulate these data.

    In addition we want to add/update 'notes' data available on purchase invoice attachment thumbnail.

    Any idea on how to do that using API ?

    Should I create a new thread for this ?

    Thanks,

    Vincent

  • Vincent D Profile Picture
    Vincent D 5 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    Thanks Inge.

    We'll try this API and share results.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 995 Super User 2024 Season 1 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    This should be possible using the attachement API

    docs.microsoft.com/.../dynamics_attachment

  • Vincent D Profile Picture
    Vincent D 5 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    We're now able to complete the full process using API

    • Define a supplier invoice Id at PO header level
    • Set receiveQuantity / invoiceQuantity at PO lines level
    • "Receive and Invoice" totally or partially the PO

    We w'd like now to either push a PDF file as an attachment to the newly created Purchase Invoice, or add a link to it using attachment note visible in UI.

    We did not find the correct way to push this information. Any suggestion ?

    Thanks,

    Vincent

  • Vincent D Profile Picture
    Vincent D 5 on at
    RE: Dynamics 365 BC - Receive and Invoice from PO using API

    Hi,

    The record update using PATCH is finally working fine with the above code, we just misunderstanding the URL scheme to be used.

    PATCH 'api.businesscentral.dynamics.com/.../{myAPIPublisher}/PurchaseOrder/v1.0/companies(99a224b4-d558-ec11-bb7c-000d3a2b9aee)/Purchaseorders(8de8bee4-d558-ec11-bb7c-000d3a2b9aee)' \

    --header 'If-Match: *' \
    --header 'Authorization: Bearer *** \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "vendorInvoiceNo": "TEST NUM"
    }'

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,836 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans