web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Initialize custom field on vendor invoice from purchase order header

(0) ShareShare
ReportReport
Posted on by

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!

I have the same question (1)
  • Verified answer
    Bill Pfingsten Profile Picture
    on at

    Hi Brawndo,

    Most scenarios still flow through the VendDocumentTableTypeBase, VendDocumentTableType, and VendDocumentTableType_Invoice classes.  Create an invoice and debug into the defaultRow(), defaultCommonFields(), and defaultAdditionalFields() methods on these classes.

    Let us know how it goes!

  • Greg's Mom Profile Picture
    on at

    Thank you so much, Bill!  We ended up adding an extension to the VendDocumentTableType_Invoice class for the defaultAdditionalFields method.  We also added a field to the VendInvoiceInfoTableTmp to hold our  our custom branch field, and created an extension to PurchFormLetterParmDataInvoice class to add our selection field in the buildCreateInvoiceHeaderFromTempTableFieldQuery method and add our field to the map in the buildCreateInvoiceFromTempTableFieldMap method.  Thanks again for your help, it got us in the right direction to get this working. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans