Skip to main content
Business Central forum
Suggested answer

Dynamics 365 BC - Receive and Invoice from PO using API

editSubscribe (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 !

Categories:
  • 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 32,714 Super User 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 32,714 Super User 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"
    }'

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,045 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,570 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans