• Home
  • About Me
  • Contact Me
  • Downloads
  • White Papers
  • Web Sites
  • Post List
  • Articles
  • FAQ

Olof Simren - Microsoft Dynamics NAV & 365 Business Central Blog

  • Home
  • About Me
  • Contact Me
  • Downloads
  • White Papers
  • Web Sites
  • Post List
  • Articles
  • FAQ

Add Fields to the Item Tracking Lines

June 7, 2016 Posted by Olof Simren Development, General, Inventory, Miscellaneous 17 Comments

This blog post is to describe how fields can be added to the Item Tracking Lines in Microsoft Dynamics NAV. Adding additional fields to this page is a common requirement; it could for example be to add a vendor lot number, some quality measurements, a manufacturing date or any other type of property that should be stored against an inventory lot or serial number.

When you first look at it seems like a simple modification but it is actually a bit (or a lot) more involved than just adding the field to the table and the page.

The Item Tracking Page is in Dynamics NAV built using a temporary table called Tracking Specification, when the page is opened there is code that populate the table with data (if there is anything to display) and when the page is closed there is code that updates the data in a different table (if there is anything to update). That different table is the reservation entry table.

Don’t ask me why it was designed like this. 🙂 It’s been like that as far as I can remember and I have learned to live with it, but I am not sure if I am a big fan of it.

Then during posting the information in the reservation entry table is retrieved and is part of the posting routine. The posting routine populates a temporary Item Journal Line table with one record per lot or serial number and this then creates the Item Ledger Entry records.

The good part with this design is that the item tracking lines page is the same across the entire application, whether you are on a purchase order, a warehouse receipt, a sales order or in an item journal, etc. it is the same page that is opened.

In this example I will add a new field called Vendor Lot No. with the intention to enable capturing the vendor’s lot number against an internal lot number in Dynamics NAV (which is a common requirement).

Adding the New Field

I start with adding the field to the tables involved in this customization, I make it a code field and 50 characters long (to be on the safer side).

New-Field-To-Tracking-Specification-Dynamics-NAV

The tables where this field needs to be added are (you can copy/paste the field between the tables):

336 – Tracking Specification

337 – Reservation Entry

83 – Item Journal Line

32 – Item Ledger Entry

Next would be to add the field to the Item Tracking Line page (which is page 6510).

New-Field-To-Item-Tracking-Lines-Page-Dynamics-NAV

You will also need to add code to this page to control when the field is editable and to store the value in the reservation entry table.

The editable or not editable feature is because the same page is used for both inbound and outbound inventory transactions, and it is only for inbound transactions you want the field to be editable. And in the case of an inbound transaction it should only be editable if the lot number doesn’t already exists (e.g. when you add to an existing lot you don’t want a different vendor lot number). Since this is exactly how the expiration date works, I will simply piggyback on that functionality. I do this by simply setting the Editable property on the new vendor lot no. field to “Expiration DateEditable”.

Editable-Property-On-Vendor-Lot-No-Dynamics-NAV

If you want to use a different logic to define if the new field should be editable or not you will have to define a new global variable and write new code on the page to set it to true or false. This can be fairly easy or very complicated, but you have some examples to use if you search the code on the page (and there is a lot of code in the item tracking lines page).

To test this I can go to an item journal, add a positive adjustment for a tracked item and open the item tracking lines. We then see that the vendor lot no. is visible and can be edited if we add a lot number that does not already exist in the database but if we add to an existing lot is not editable. Then when we do a negative adjustment it is not edible. Perfect! 🙂

Item-Tracking-Lines-Test-Item-Journal-Dynamics-NAV

Next step is to make sure the data in the new field is stored in the reservation entry table when the page is closed. If you came this far and tested the solution then you will notice that if you close the item tracking lines page and open it again the information in the new field is gone. So, kind of useless so far, but hold on. 🙂

Storing it in the Reservation Entry Table

So to do this we open the code in the item tracking lines page and add the below lines (in this case I basically just searched for the expiration date and added my own lines of code under it since I know that my new field should work the same way);

First change is to add the below code to the RegisterChange function (this function runs when the page is closed):

RegisterChange-Function-Item-Tracking-Lines-Page-Dynamics-NAV

As you can see this code calls a new function in the reservation entry table that we also need to add, it can look like below (as simple as possible);

Add-Vendor-Lot-No-Reservation-Entry-Dynamics-NAV

If I then continue my search for the expiration date in the code of the item tracking lines page I will find some additional places where I need to add my new field, actually two more places in the same RegisterChange function;

RegisterChange-Function-2-Item-Tracking-Lines-Page-Dynamics-NAV

Next thing to change is in the EntriesAreIdentical function, this function is used in the RegisterChange function that was modified previously and determines if there are reservation entries that are the same and should be updated.

EntriesAreIdentical-Function-Item-Tracking-Lines-Page-Dynamics-NAV

The next place to add code to is in the ModifyFieldsWithinFilter function.

ModifyFieldsWithinFilter-Function-2-Item-Tracking-Lines-Page-Dynamics-NAV

Last we have the function RegisterItemTrackingLines that needs to be modified according to below.

RegisterItemTrackingLines-Item-Tracking-Lines-Page-Dynamics-NAV

Again, like the rest of the places above where we have added code we are just following the footsteps of Microsoft by looking at the standard expiration date field and mimicking that code (therefor a lack of explanations to some of the changes).

If you test the functionality now you will notice the data in the vendor lot no. field is stored in the reservation entry table when you leave the item tracking lines page and it is retrieved again when you open the page.

Changing the Posting Routine

Now we have a place where we can enter the vendor lot no. and it gets stored in the reservation entry table. Next thing to do is to make sure this information is transferred to the item ledger entry during posting. As described earlier the code for posting inventory transactions first generates records in a temporary item journal line table and from there the item ledger entries are created. This all happens in codeunit 22 – Item Jnl.-Post Line, so lets open it in design mode and search for the expiration date (since we are lazy we don’t want to read the entire code, just search and do our additions).

When you search for expiration date in codeunit 22 you will notice that there is code to handle changes to the expiration dates, to check if expiration dates are present if mandatory and to calculate the expiration date during posting. Right now we can just find the places that populates the item journal line and then the item ledger entry table (I will get back to changing and making our new field mandatory later).

The first place to change is in the SetupTempSplitItemJnlLine function. This is the function that looks at the item tracking stored in the reservation entry table and creates a temporary record for each lot/serial number in the item journal line table. The code to add is as follows;

SetupTempSplitItemJnlLine-Codeunit-22-Dynamics-NAV

The other place is in the InitItemLedger function, this is what moves the data from the temporary item journal line table to the item ledger entry table.

InitItemLedger-Codeunit-22-Dynamics-NAV

Done! If you post a positive adjustment (or any other type of inbound item transaction) now you should see the vendor lot no. populated on the item ledger entries.

Assigning the value on Outbound Transactions

We have done the part that stores the vendor lot number in the reservation entry table and that adds it to the item ledger entry table during posting. What is left is to make sure it also default into the item tracking lines when an existing lot is selected for an outbound transaction.

There are two places where you need to add code for this, one is in the tracking specification table when the serial or lot number is entered and the other is in the page if it gets opened for something that already have a serial or lot number assigned to it.

For the table; we can do it the same way as Microsoft have done it for the expiration date, so we create a new function called InitVendorLotNo in the table that looks like below (basically a copy of the standard InitExpirationDate function).

InitVendorLotNo-Tracking-Specification-Dynamics-NAV

This new function is then called on the OnValidate triggers of the serial and lot no. fields.

OnValidate-LotNo-Tracking-Specification-Dynamics-NAV

The ExistingVendorLotNo function in the Item Tracking Management codeunit that is referred to in the new function is kind of the same as the existing one for the expiration date (so I just copied the one called ExistingExpirationDate and changed it to below).

ExistingVendorLotNo-Item-Tracking-Management-Dynamics-NAV

The above is when the serial or lot number is entered, if the item tracking lines pages is closed and then opened again you need to put some additional code to the page to retrieve the vendor lot no., this code is in the AddToGlobalRecordSet function and looks like below (as you can see it uses the same function as the OnValidate code in the table).

AddToGlobalRecordSet-Item-Tracking-Lines-Page-Dynamics-NAV

Now when we do a negative transaction in the item journal we can see that the vendor lot no. defaults from the lot we select. Nice!

Item-Ledger-Entries-Dynamics-NAV

An Alternative to the Item Ledger Entries

An alternative to storing the new field on item ledger entries is to use the tables called Lot No. Information (6505) and Serial No. Information (6504) to store the vendor lot no.

What you need to do in this case is to make sure those records are always created when inventory is added and then add the vendor lot no. field in that table instead of to the item ledger entries (all through codeunit 22). This is less programming and will be simpler if you want to change the vendor lot no. (you then just change it on the card of the lot or serial number), but it will not be transactional based and it will be slightly different compared to how Microsoft have done it with the other fields.

Changing an Existing Lot or Serial No.

Creating the code that allows you to change the Vendor Lot No. using the item reclassification journal (the same way as you can change the expiration date) is a topic by itself. If you have followed what I described above you have probably noticed that in a couple of places there are fields that starts with ‘New’ like New Expiration Date, New Lot No., etc… So to have a proper feature to update the vendor lot no. on an existing lot you will have to add the New Vendor Lot No. field to the same tables (except the item ledger entry table) and add lines of code to handle that part as well (again mimic the standard functionality around expiration dates).

I might do a future post describing this (like a part 2) and also how to make a new field like this mandatory when adding new lots to inventory.

This blog post turned our way more technical that what I initially had planned, but I guess that’s the nature of adding a field to the item tracking lines.

That’s all for this blog post, thanks for following and have a great day!

Remember to share this post as well! 🙂

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X

Related


Discover more from Olof Simren - Microsoft Dynamics NAV & 365 Business Central Blog

Subscribe to get the latest posts sent to your email.

Tags: DevelopmentInventoryItem TrackingItem Tracking LinesLot No.Serial No.Vendor Lot No.
17 Comments
Share
7

About Olof Simren

I am a Microsoft Dynamics NAV and 365 Business Central Expert, I started implementing Microsoft Dynamics NAV in 2002, back then it was called Navision Attain. Throughout the years there has been many exciting implementations in different parts of the world, all of them with different challenges but with one common theme; manufacturing. As a consultant, I bring over 20 years of experience in implementing Microsoft Dynamics NAV and 365 Business Central within manufacturing and distribution companies. The services I offer includes project management, consultation, development and training. Feel free to contact me if you need help with anything related to Microsoft Dynamics NAV or 365 Business Central. I work through my company Naviona where I team up with other skilled Microsoft Dynamics NAV and 365 Business Central Experts.

You also might be interested in

Default Dimension Priorities for Production Order Components

May 4, 2014

In one of my earlier blog posts, Dimensions on Production[...]

Write C/AL Code in Excel

Sep 22, 2014

This is something that I did some days ago and[...]

Multiple Item Unit of Measures

Apr 11, 2014

Items in Microsoft Dynamics NAV can have multiple units of[...]

17 Comments

Leave your reply.
  • Erik P. Ernst
    · Reply

    June 7, 2016 at 8:34 AM

    Hi Olof,
    As always a great post! Nice to see that I’ve been doing it “correctly” all those years… I too find that the areas around item tracking is “strangely” designed. Very different from other areas of NAV. Personally I normally use the Lot/Serial No. Information tables, if it’s much more than a single field, like when I’ve had to implement the EU’s fishing industry trackings (an industry I’m sure you’re also familiar with on Iceland).

    • Olof Simren
      · Reply

      Author
      June 7, 2016 at 9:44 AM

      Hi Erik,
      Thanks for your comments.
      Good point, agree, if you’re adding many fields that would be the better way.
      I am not from Iceland, I am Swedish living in Florida. 🙂

      Cheers!

      /Olof

  • Nermin Montel
    · Reply

    June 7, 2016 at 9:07 AM

    Thank you very much. To be honest I lost a lot of hours tracking the same functionality.
    This will go as favorites 

  • Rick Blom
    · Reply

    June 7, 2016 at 12:43 PM

    Hi Olof,

    Been there many times. You can add this at quite some more tables, pages and cu, when integrating this with WMS.

    Would be great if we somehow can use extensions/events to solve this much less upgrade efforts

    Rick

  • Antonio
    · Reply

    June 7, 2016 at 1:26 PM

    Great post as usual!
    I keep my best thoughts on Microsoft designers when I get this kind of indescriptible error message related to item tracking making warehouse due to a rebel lot no.
    Thank you Olof.

  • Erik P. Ernst
    · Reply

    June 8, 2016 at 6:57 AM

    Knew the Florida part, just not the Swedish. Always forget you also have NAV in Sweden. Sorry… But then again, when I started NAV was only available in DK, Germany and Iceland… So saying Iceland was a positive thing. 🙂
    Have a great day!

  • Peter Skogberg
    · Reply

    September 28, 2016 at 2:48 AM

    Thank you, this saved me when coding last night in a hurry :)!

  • A Random Passer-by
    · Reply

    October 1, 2016 at 4:51 PM

    Hi Olof,

    This article could use some warnings I’m afraid.

    Without any extra modifications, functions like Requisition Worksheet or Production Planning will “erase” your added fields.
    Executing Report 699 for instance will recreate all reservation entries for the items in the planning process. Without modification to for instance the function TransferToTrackingEntry in the Inventory Profile Table (99000853) your added fields won’t be copied to the new entries and effectively will be “erased”.

    I’ll spare you the details if you would be trying to add “Quantity”-like fields. That’s just a no go.
    In the end you’ll find yourself in a maze of splitting lines and (un)tracked quantities in which even the regular quantity fields loose track.

    • Olof Simren
      · Reply

      Author
      October 2, 2016 at 7:40 AM

      Hi,
      Thank you for your comment.
      I understand your concern, but I am not sure I see this as a real world issue.
      The item tracking lines are a method to add lot or serial information when doing an inventory transaction, and once posted the information is moved to the item ledger.
      I can see the issue if you are running a material plan during the day when people are doing transactions. I don’t know anybody doing that since this introduces a whole range of other issues.
      But it is good to know what you have discovered, I appreciate your feedback.

      /Olof

  • Tina Menezes
    · Reply

    November 21, 2016 at 11:01 PM

    Hi,
    Thanks a lot for this article.
    I want to do the same process you have described above using extensions in NAV. But using extensions I cannot modify existing codeunit 6500. Can you give me some solution as to how this can be done then?
    Thanks.

    • Olof Simren
      · Reply

      Author
      November 22, 2016 at 11:58 AM

      Hi Tina,
      Why can’t you make the modifications to the codeunit and create an extension for it?

      /Olof

      • Tina Menezes
        · Reply

        November 22, 2016 at 10:17 PM

        Hi Olof Simren,
        When I make modifications to the existing codeunit, it gives me an error that it is an existing system codeunit hence modifications cannot be made to it. So is there any alternative to this ?

        • Olof Simren
          · Reply

          Author
          November 23, 2016 at 9:01 AM

          Hi Tina,
          I see, try to put the code in the table or in a new codeunit instead.
          I believe that in the versions up until now you can’t change the code in an existing codeunit and have it part of an extension. So, you should either use the events (which is not an option in this case) or put the code somewhere else.

          /Olof

  • Preetham
    · Reply

    March 22, 2017 at 2:19 PM

    This is a great post that saved me hours to search for the code. Thanks a lot.

  • Jim
    · Reply

    May 11, 2017 at 6:30 PM

    Olof, I must say that this is one of the best posts I’ve come across in a long time! This is a page I’ve bookmarked. It has already saved me tons of time, and I’m sure it will in the future as well. A great job of explaining a rather complex functionality. Thank You, Thank You, Thank You!

  • Joe
    · Reply

    May 24, 2018 at 10:41 AM

    I’ve been wanting to do this for a year and finally got my developers license. Completely self taught so pardon me if this question is elementary…

    If I wanted to display the related “Vendor Lot No.” (I’m tracking steel heat lots) on Page 6520 Item Tracing, would this whole process need to be repeated for the “Item Tracing Buffer” table and this page? I guess I’m not seeing the connection between the two tables.

    Any other resources you can point to for heat tracking?

  • Sunny
    · Reply

    December 16, 2019 at 6:01 AM

    Olaf thanks for sharing great thought. I am also struggling with the same feature to use. we made customization and its working fine accept WMS activity. i tried to figure out issue but unable to resolve. inward WMS is using customization code so data stored till ILE but while making out it stays till warehousing shipment once it comes to Pick area customization field to lose their details. can you share information if you had done any changes? in it.

    #Sunny

Leave a Reply

Your email is safe with us.
Cancel Reply

My Dynamics NAV Partner

Naviona, LLC

Developers Wanted

Naviona is looking for NAV/BC developers. Let me know if you want to work with the best (instead of the rest :-)).

Categories

  • Assembly (3)
  • Development (31)
  • Finance (14)
  • General (26)
  • Inventory (22)
  • Manufacturing (34)
  • Miscellaneous (25)
  • Purchase (9)
  • Sales (11)
  • Warehouse (7)

Tags

.net Add-in Assembly Assembly BOM CAL Capacity Components Consumption Contact Costs Customer Development Dimensions Excel Finance Flushing General Ledger Inventory Item Items Lot Size Low-Level Code MRP NAV 2015 NAV 2016 Output PDF Planning Production Production BOM Production Orders Purchase Orders Receipts Reporting Reports Role Center Routing Sales Sales Order Sales Orders Stockkeeping Unit Subcontracting Task List Warehouse Warehouse Shipment

Recent Posts

  • XML Buffer and CSV Buffer Tables
  • Functionality Improvements in NAV 2017
  • Reversing Production Output and Consumption
  • Return Merchandise Authorization (RMA)
  • Sales Quote without Customer
  • Parallel Routings
  • Add Fields to the Item Tracking Lines
  • Field Level Security using Events in Dynamics NAV 2016
  • Schedule MRP
  • Activate WMS Functionality for Existing Location

Categories

  • Assembly
  • Development
  • Finance
  • General
  • Inventory
  • Manufacturing
  • Miscellaneous
  • Purchase
  • Sales
  • Warehouse

Contact Us

We're currently offline. Send us an email and we'll get back to you, asap.

Send Message

Categories

  • Assembly (3)
  • Development (31)
  • Finance (14)
  • General (26)
  • Inventory (22)
  • Manufacturing (34)
  • Miscellaneous (25)
  • Purchase (9)
  • Sales (11)
  • Warehouse (7)

Tags

.net Add-in Assembly Assembly BOM CAL Capacity Components Consumption Contact Costs Customer Development Dimensions Excel Finance Flushing General Ledger Inventory Item Items Lot Size Low-Level Code MRP NAV 2015 NAV 2016 Output PDF Planning Production Production BOM Production Orders Purchase Orders Receipts Reporting Reports Role Center Routing Sales Sales Order Sales Orders Stockkeeping Unit Subcontracting Task List Warehouse Warehouse Shipment

Recent Posts

  • XML Buffer and CSV Buffer Tables
  • Functionality Improvements in NAV 2017
  • Reversing Production Output and Consumption
  • Return Merchandise Authorization (RMA)
  • Sales Quote without Customer
  • Parallel Routings
  • Add Fields to the Item Tracking Lines
  • Field Level Security using Events in Dynamics NAV 2016
  • Schedule MRP
  • Activate WMS Functionality for Existing Location

Recent Comments

  • Isabel de los Santos on Production Lot Sizes
  • Abdelatif EL HANI on Reversing Production Output and Consumption
  • Roshan on Processing of Receipts
  • kuldeep Nama on Subcontracting Part 1: The Basics
  • Janine on Flushing Methods
  • Nathalie on Activate WMS Functionality for Existing Location
  • Georges W on Bill-to vs. Sell-to Customer
  • Richard L on Subcontracting Part 4: Warehouse Receipts

© 2025 · Olof Simren

  • Home
  • About Me
  • Contact Me
  • Downloads
  • White Papers
  • Web Sites
  • Post List
  • Articles
  • FAQ
Prev Next