Add Location Code field in VAT Entry table


Is it possible too add a new field "Location Code " in VAT Entry table where, this new field “Location Code” should be taken from Sales Invoice Header.?

I create a function in a codenit:

LOCAL FillLocationCode()
UpdateVATEntry := FALSE;
IF (VATEntry.“Document No.” <> ‘’) THEN BEGIN
IF (VATEntry.“Location Code” = ‘’) THEN BEGIN
IF SalesInvoiceHeader.GET(VATEntry.“Document No.”) THEN BEGIN
IF (VATEntry.“Location Code” = ‘’) AND (SalesInvoiceHeader.“Location Code” <> ‘’) THEN BEGIN
VATEntry.“Location Code” := SalesInvoiceHeader.“Location Code”;
UpdateVATEntry := TRUE;

but the new field Location Code is not updated.

Please can you help me?

I suggest you to follow the next method to post new fields in VAT Entry (and others tables related to G/L Entry):

  • Create the field in table 81, optionally with the same ID as VAT Entry
  • Optionally you can show this new field in General Ledger pages.
  • In codeunit 80/90 Look for where the system copy header (or line, but this is more complicated because it use a buffer table to group data) information to general ledger and add the code to transfer value. From NAV 2018 you can use an event subscriber function to do that work and doesn’t need to modify those codeunits, in this case, the publisher events are in table 81: OnAfterCopyGenJnlLineFromPurchHeader or OnAfterCopyGenJnlLineFromSalesHeader.
  • In codeunit 12 look for where system create VAT Entry (or other entry table) and transfer the value from table 81 to 254. From NAV 2018 you can use an event subscriber function to do that, in table 254, you have to connect to publisher event OnAfterCopyFromGenJnlLine.

This method is valid to copy values from sales/purchase header to entry tables (G/L Entry, VAT Entry, Cust. Ledger Entry, Vend. Ledger Entry, …), you will need to find the exact place or event to connect to, for each table. If you want to copy values from sales/purchase lines, it’s more difficult, but I will let you try :wink:

Hi MariNav123 ,

Have this helped to solve your issue? If it has, please, verify it as the solution.

If it hasn’t, have you solved the issue otherwise? If it is, please, let us know how, and verify it as the solution.

Hi Ponç J. Llaners,

I added code in CU12 in Insert VAT () function to have the lief updated after I post a Sales Order

Thank you for your help.