Hello there,
I have added a custom field (Branch) onto the purchase order header (PurchTable) and the vendor invoice header (VendInvoiceInfoTable) via table extensions. When generating a vendor invoice from a purchase order, I would like to default the value of my custom field from the purchase order onto the vendor invoice. I thought this will be simple by extending the VendInvoiceInfoTable.initFromPurchTable method but I do not see initFromPurchTable being called. I also thought to extend the insert method on VendInvoiceInfoTable, look up the related PurchTable record and set my custom branch field but that is also not being hit. I found in PurchFormLetterParmDataInvoice class the method createInvoiceHeaderFromTempTable and it has this chunk of code to insert from a query and skip the events and table methods:
vendInvoiceInfoTable.skipEvents(true);
vendInvoiceInfoTable.skipDataMethods(true);
vendInvoiceInfoTable.skipDatabaseLog(true);
Query::insert_recordset(vendInvoiceInfoTable, targetToSourceMap, query);
Am I doing something terribly wrong or is defaulting a value from PurchTable to VendInvoiceInfo table a little more complicated in D365? I started looking into how to create a table map extension because it looks like the standard code is initializing the out of the box fields on vendor invoice from a purchase order using table maps. Do I need to look into these table map extension topics to get this done?
https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/map-extensions
https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/maps-as-interfaces
These looked a little complicated and I worried I'm going down a rabbit hole and wanted to reach out to the experts to ensure I'm not missing something obvious. Any help would be greatly appreciated!