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):