How to add new fields to the Item Tracking Lines form

Photo credit: Bruno Girin
The Item Tracking Lines form has a Source Table of Tracking Specification.
The Tracking Specification table is used in conjunction with theResrevation Entry table, Item Ledger Entry table and various temporary record handling functionality in order to attach and maintain tracking against items on document lines.
To add a new field, for example, Your Reference, you must first add this field to the Tracking Specification table and place it on screen by modifying the Item Tracking Lines form:
Reservation Entry
The new field also needs to be added to the Reservation Entry table.
Unfortunately there is more to it than just placing the field on screen. If you try to assign a lot and fill in our new Your Reference field, close the form, then re-open, you’ll notice that the value entered has disappeared.
This is beause the new field needs to be pushed through to the Reservation Entry table.
To achieve this we need to delve into the code behind the Item Tracking Lines form.
RegisterChange
The first function we need to look at is the the RegisterChange function.
Within this function there is a call to the CreateReservEntryFor function in the Create Reserv. Entrycodeunit. Values are passed to this function which is then used to update the reservation entries.
You can either modify the CreateReservEntryFor function and tag your field(s) on the end, or create a new function called SetCustomFields which will take your new field(s) as parameters.
The new function should look something like this:
-
InsertReservEntry."Your Reference" := YourReference;
-
InsertReservEntry2."Your Reference" := YourReference;
A call to this new function must then be made from the RegisterChange function in the Item Tracking Lines form.
-
IF CurrentSignFactor < 0 THEN
-
NewTrackingSpecification."Expiration Date" := 0D;
-
-
CASE ChangeType OF
-
ChangeType::Insert:
-
BEGIN
-
IF (OldTrackingSpecification."Quantity (Base)" = 0) OR
-
((OldTrackingSpecification."Lot No." = '') AND
-
(OldTrackingSpecification."Serial No." = ''))
-
THEN
-
EXIT(TRUE);
-
TempReservEntry.SETRANGE("Serial No.",'');
-
TempReservEntry.SETRANGE("Lot No.",'');
-
OldTrackingSpecification."Quantity (Base)" :=
-
CurrentSignFactor *
-
ReservEngineMgt.AddItemTrackingToTempRecSet(
-
TempReservEntry,NewTrackingSpecification,
-
CurrentSignFactor * OldTrackingSpecification."Quantity (Base)",QtyToAddAsBlank,
-
ItemTrackingCode."SN Specific Tracking",ItemTrackingCode."Lot Specific Tracking");
-
TempReservEntry.SETRANGE("Serial No.");
-
TempReservEntry.SETRANGE("Lot No.");
-
-
// Late Binding
-
IF ReservEngineMgt.RetrieveLostReservQty(LostReservQty) THEN BEGIN
-
TempItemTrackLineReserv := OldTrackingSpecification;
-
TempItemTrackLineReserv."Quantity (Base)" := LostReservQty * CurrentSignFactor;
-
TempItemTrackLineReserv.INSERT;
-
END;
-
-
IF OldTrackingSpecification."Quantity (Base)" = 0 THEN
-
EXIT(TRUE);
-
-
IF (FormRunMode = FormRunMode::Reclass) OR MoveBinContent THEN BEGIN
-
CreateReservEntry.SetNewSerialLotNo(
-
OldTrackingSpecification."New Serial No.",OldTrackingSpecification."New Lot No.");
-
CreateReservEntry.SetNewExpirationDate(OldTrackingSpecification."New Expiration Date");
-
END;
-
CreateReservEntry.SetDates(
-
NewTrackingSpecification."Warranty Date",NewTrackingSpecification."Expiration Date");
-
CreateReservEntry.SetApplyFromEntryNo(
-
NewTrackingSpecification."Appl.-from Item Entry");
-
-
CreateReservEntry.SetCustomFields("Your Reference"); // — INSERT LINE ++
-
-
CreateReservEntry.CreateReservEntryFor(
-
..
-
..
The new field will now be pushed through to the reservation entry table when the item tracking form is in insert mode.
It also needs to update correctly when in modify/delete mode.
EntriesAreIdentical
To do this you firstly need to modify the EntriesAreIdentical function by inserting the new Your Reference field as follows:
-
..
-
IdenticalArray[2] := (
-
(ReservEntry1.Description = ReservEntry2.Description) AND
-
(ReservEntry1."New Serial No." = ReservEntry2."New Serial No.") AND
-
(ReservEntry1."New Lot No." = ReservEntry2."New Lot No.") AND
-
(ReservEntry1."Expiration Date" = ReservEntry2."Expiration Date") AND
-
(ReservEntry1."Warranty Date" = ReservEntry2."Warranty Date") AND
-
(ReservEntry1."Your Reference" = ReservEntry2."Your Reference") AND // — INSERT LINE ++
-
(ReservEntry1."New Expiration Date" = ReservEntry2."New Expiration Date"));
-
EXIT(IdenticalArray[1] AND IdenticalArray[2]);
RegisterChange
Now we need to go back to the RegisterChange function and insert the following two lines of code which fall within ChangeType::Modify: case statement.
This code will update the reservation entries correctly when our new field Your Reference is modified.
-
-
// Late Binding
-
IF ReservEngineMgt.RetrieveLostReservQty(LostReservQty) THEN BEGIN
-
TempItemTrackLineReserv := OldTrackingSpecification;
-
TempItemTrackLineReserv."Quantity (Base)" := LostReservQty * CurrentSignFactor;
-
TempItemTrackLineReserv.INSERT;
-
END;
-
-
OldTrackingSpecification."Quantity (Base)" := QtyToAdd;
-
OldTrackingSpecification."Warranty Date" := NewTrackingSpecification."Warranty Date";
-
OldTrackingSpecification."Expiration Date" := NewTrackingSpecification."Expiration Date";
-
OldTrackingSpecification.Description := NewTrackingSpecification.Description;
-
// — INSERT FOLLOWING LINE ++
-
OldTrackingSpecification."Your Reference" := NewTrackingSpecification."Your Reference";
-
RegisterChange(OldTrackingSpecification,OldTrackingSpecification,
-
ChangeType::Insert,NOT IdenticalArray[2]);
-
END ELSE BEGIN
-
TempReservEntry.SETRANGE("Serial No.",OldTrackingSpecification."Serial No.");
-
TempReservEntry.SETRANGE("Lot No.",OldTrackingSpecification."Lot No.");
-
OldTrackingSpecification."Serial No." := '';
-
OldTrackingSpecification."Lot No." := '';
-
OldTrackingSpecification."Warranty Date" := 0D;
-
OldTrackingSpecification."Expiration Date" := 0D;
-
// — INSERT FOLLOWING LINE ++
-
OldTrackingSpecification."Your Reference" := '';
-
QtyToAdd :=
ModifyFieldsWithinFilter
Lastly we need to add a line of code to the ModifyFieldsWithinFilter function:
-
IF ReservEntry1.FIND('-') THEN
-
REPEAT
-
ReservEntry1.Description := TrackingSpecification.Description;
-
ReservEntry1."Warranty Date" := TrackingSpecification."Warranty Date";
-
ReservEntry1."Expiration Date" := TrackingSpecification."Expiration Date";
-
ReservEntry1."New Serial No." := TrackingSpecification."New Serial No.";
-
ReservEntry1."New Lot No." := TrackingSpecification."New Lot No.";
-
ReservEntry1."New Expiration Date":= TrackingSpecification."New Expiration Date";
-
// — INSERT FOLLOWING LINE ++
-
ReservEntry1."Your Reference":= TrackingSpecification."Your Reference";
-
ReservEntry1.MODIFY;
-
UNTIL ReservEntry1.NEXT = 0;
The new field should now be fully operational.









2 Comments
Belias
hi, i found 2 more places that we need to update, i’ll post here a link to mibuso, where the discussion started (and where i posted a piece of code)
http://www.mibuso.com/forum/viewtopic.php?f=23&t=41397&p=204057#p204057
The 2 functions you didn’t wrote in your (wonderful) blog post, allow us to keep our new fields after posting a transfer order or a production order.
to avoid my cross posting, can you update your blog post when possible, please?
Thanks for your effort!!!
May 19th, 2010
Leave a response