0

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
  • Set receiveQuantity / invoiceQuantity
  • 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 ?

ps: We have found a project on github written by ethan-sorenson (here) but not applicable in our context...

Thanks !

1 Answers1

0

You should be able to accomplish this by using the bound action ReceiveAndInvoice on the Purchase Orders API.

The endpoint should look (something) like this:

https://api.businesscentral.dynamics.com/v2.0/{environment}/api/v1.0/companies({id})/purchaseOrders({id}})/Microsoft.NAV.receiveAndInvoice

For more information you can check out this blog post.

kaspermoerch
  • 16,127
  • 4
  • 44
  • 67
  • Hi, calling this bound action results in "BadRequest_NotFound". Where did you find this boud action (ReceiveAndInvoice) ? The documentation [here](https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/resources/dynamics_purchaseorder) does not mention any bound action available on PO. – Vincent-ks2 Jan 07 '22 at 14:14
  • But even in AL language, where to find documentation to manipulate PO / PO lines ? – Vincent-ks2 Jan 07 '22 at 14:16
  • I found it in the source code. Which version of Business Central are you running on? – kaspermoerch Jan 10 '22 at 06:37
  • Hi, V 19.1.31886.32222 (Dynamics 365 version). Sorry for this dummy question, but where do you find source code ? – Vincent-ks2 Jan 10 '22 at 13:52
  • If you use Docker for development and create a container for your version, then you can find the source code in C:\bcartifacts.cache. – kaspermoerch Jan 11 '22 at 07:04
  • Here is the source code: https://github.com/microsoft/ALAppExtensions/tree/4519eea4a265dda64dd53c0ff5d60d89333842ad/Apps/W1/APIV2/app/src/pages – Vincent-ks2 Jan 12 '22 at 08:28
  • Yes, the bound action exists ( [source code](https://github.com/microsoft/ALAppExtensions/blob/4519eea4a265dda64dd53c0ff5d60d89333842ad/Apps/W1/APIV2/app/src/pages/APIV2PurchaseOrders.Page.al) and should be called using camel case: Microsoft.NAV.receiveAndInvoice – Vincent-ks2 Jan 12 '22 at 08:31
  • Perfect. I have edited my answer accordingly. – kaspermoerch Jan 12 '22 at 09:56