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

Announcements

News and Announcements icon
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
    Microsoft Employee 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
SajeedMullaji Profile Picture

SajeedMullaji 698

#2
Martin Dráb Profile Picture

Martin Dráb 327 Most Valuable Professional

#3
CU10121822-0 Profile Picture

CU10121822-0 320

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans