Monday, 12 November 2018

Job to create vendor invoice (PO) through X++ code in D365

A vendor invoice for a purchase order is an invoice that is attached to a purchase order. It contains a header and one or more lines for items or services. A vendor invoice finishes the purchase order, product receipt, and vendor invoice cycle.

In this blog I will discuss how to create purchase order invoice through X++ code in Microsoft Dynamics 365 finance & operation.

For this example I have created a job, please see source code screenshots below.

Source code explanation (1.1):
  • Initialize classes and tables buffers.
  • Get purchase order through find method.
  • Check Product receipt for the relevant purchase order exists.




















Source code explanation (1.2):

  • Populate data for insertions in Vendor invoice info table.
  • Call insert method of table.


















Source code explanation (1.3):

  • Insert data in VendInvoiceInfoSubTable .
  • Get product receipt lines for iteration, and populate invoice lines accordingly.



















Source code explanation (1.4):
  • Insert data in vendor invoice info lines.
  • Call insert method of table.














Source code explanation (1.5):
  • Insert data in VendInvoiceInfoSubLine table.
  • Call insert method of the table.
  • Info message for success.


















That is all you need to do, now build and run the job. 

Result



3 comments:

  1. Aslamo ali kum!
    i am having error on SLD_WorkProgressAndIPCCONSANT.
    error descrioption: The qualifier SLD_WorkProgressAndIPCCONSANT is not valid for field zero.

    ReplyDelete
    Replies
    1. Please ignore this, as it is the constant file used in my code. For your code you can use constants in file or use directly as literal strings.

      Delete
  2. Could it be possible to create a vendor invoice attached to multiple purchase orders ? If so, what changes would you make in your code ?

    ReplyDelete

How to Get Customer Free Text Invoice "Totals" form field value with X++ in D365FO

Customer free text invoices are an essential aspect of financial management in D365FO. In this blog, I have compiled all the code needed to ...