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 :
Small and medium business | Business Central, N...
Suggested Answer

Update Item Tracking in Sales Lines & Whse. Shipment Lines

(5) ShareShare
ReportReport
Posted on by 301
Hello, 
           I have to update the Item Tracking lines in Sales Lines (order) and Whse. Shipment Lines(created from that) , but these both should be updated when the Item Tracking Lines of Assembly Order Lines are updated ( also when updating lines of the Assembly Order Header's Item Tracking should be updated with same data- which is getting updated via below given Event Subscriber Code ). So suggest me code for updating the Sales Line (order) and Whse. Shipment Lines. Either by event subscriber or by any action in Line or Header Item Tracking of Assembly Order - so that same data passes to the Sales Lines and Whse. Shipment Lines.
 
[EventSubscriber(ObjectType::Table, Database::"Reservation Entry", OnAfterCopyTrackingFromTrackingSpec, '', true, true)]
 local procedure OnAfterCopyTrackingFromTrackingSpec(var ReservationEntry: Record "Reservation Entry"; TrackingSpecification: Record "Tracking Specification")
 var
 TrackSpecs: Record "Tracking Specification";
 LastEntryNo: Integer;
 AssemblyHeader: Record "Assembly Header";
 ReservEntry: Record "Reservation Entry";
 LastReservEntryNo: Integer;
 l: page "Item Tracking Lines";
 begin
 if TrackingSpecification."Source Type" <> Database::"Assembly Line" then
 exit;
 if TrackingSpecification."Serial No." = '' then
 exit;
 // Find Assembly Header
 AssemblyHeader.Reset();
 AssemblyHeader.SetRange("Document Type", TrackingSpecification."Source Subtype");
 AssemblyHeader.SetRange("No.", TrackingSpecification."Source ID");
 if not AssemblyHeader.FindFirst() then
 exit;
 
 ReservEntry.Reset();
 if ReservEntry.FindLast() then
 LastReservEntryNo := ReservEntry."Entry No."
 else
 LastReservEntryNo := 0;
 
 ReservEntry.Init();
 ReservEntry."Entry No." := LastReservEntryNo + 1;
 ReservEntry.Positive := true;
 ReservEntry.Validate("Item No.", AssemblyHeader."Item No.");
 ReservEntry.Validate("Location Code", AssemblyHeader."Location Code");
 ReservEntry.Validate("Quantity", TrackingSpecification."Quantity (Base)");
 ReservEntry.Validate("Quantity (Base)", TrackingSpecification."Quantity (Base)");
 ReservEntry.Validate("Qty. to Handle (Base)", TrackingSpecification."Qty. to Handle (Base)");
 ReservEntry.Validate("Qty. to Invoice (Base)", TrackingSpecification."Qty. to Invoice (Base)");
 ReservEntry."Qty. per Unit of Measure" := TrackingSpecification."Qty. per Unit of Measure";
 ReservEntry."Reservation Status" := ReservEntry."Reservation Status"::Surplus;
 ReservEntry."Source Type" := Database::"Assembly Header";
 ReservEntry."Source Subtype" := TrackingSpecification."Source Subtype";
 ReservEntry."Source ID" := TrackingSpecification."Source ID";
 ReservEntry."Source Ref. No." := 0;
 ReservEntry.Validate("Serial No.", TrackingSpecification."Serial No.");
 ReservEntry.Validate("Lot No.", TrackingSpecification."Lot No.");
 ReservEntry."Creation Date" := Today;
 ReservEntry.Insert(true);
 end;
 
 
I have the same question (0)
  • Suggested answer
    OussamaSabbouh Profile Picture
    17,586 Super User 2026 Season 1 on at
    Hello,
    I would not insert Reservation Entry records manually for Sales Lines or Warehouse Shipment Lines; item tracking in BC is tied to reservations/order tracking, and Microsoft’s design docs are clear that Sales, Assembly, Warehouse and Item Tracking all depend on table 337 Reservation Entry + table 336 Tracking Specification, so direct inserts can easily create broken tracking, warehouse pick/shipment issues, or duplicate surplus entries. For an Assemble-to-Order flow, the correct link is normally already there: the assembly output is reserved against the sales line, and warehouse shipment follows that demand; so the safer approach is to update tracking through the standard Item Tracking Lines / Reservation Management logic, not by copying rows yourself. Practically, I’d trigger after the assembly tracking change, find the linked Sales Line from the ATO reservation/order-to-order link, then call standard item tracking/reservation functions for that sales line, and recreate/update the Whse. Shipment only if needed; if a Warehouse Shipment already exists, you may need to delete/recreate the shipment line or pick, because warehouse documents often copy tracking/quantities at creation time. Your current subscriber is risky because it creates a new positive Surplus reservation entry on the Assembly Header; instead, use the existing reservation pair between Assembly Header and Sales Line and update the tracking there. 
    Regards,
    Oussama Sabbouh
  • Assisted by AI
    Saif Ali Sabri Profile Picture
    2,654 Moderator on at

    You are right to avoid manually inserting Reservation Entry records for Sales Line / Whse. Shipment Line tracking synchronization.
    In Business Central, Item Tracking propagation should always go through the standard reservation + tracking framework, otherwise you can easily end up with:

    • orphan reservation entries
    • duplicate surplus entries
    • broken order tracking
    • warehouse shipment/pick inconsistencies
    • posting errors later

    Your current subscriber:

    OnAfterCopyTrackingFromTrackingSpec

    reates a new Surplus entry directly on the Assembly Header, but that does not update the existing reservation chain between:

    • Assembly Order
    • Sales Order Line
    • Warehouse Shipment Line

    For an Assemble-to-Order scenario, BC already creates reservation/order tracking links automatically.

    The safer approach is:

    1. Detect tracking change on Assembly Order
    2. Find the linked Sales Line through Reservation Entry
    3. Update tracking using standard Item Tracking / Reservation Management codeunits
    4. Recreate or refresh Warehouse Shipment if required

    5.  

    Example approach:
     

    local procedure UpdateSalesTrackingFromAssembly(AssemblyHeader: Record "Assembly Header")
    var
        ReservEntry: Record "Reservation Entry";
        SalesLine: Record "Sales Line";
    begin
        ReservEntry.Reset();
        ReservEntry.SetRange("Source Type", Database::"Assembly Header");
        ReservEntry.SetRange("Source ID", AssemblyHeader."No.");
        if ReservEntry.FindSet() then
            repeat
                // Find linked Sales Line
                if (ReservEntry."Transferred from Entry No." <> 0) then begin
                    if SalesLine.Get(
                        SalesLine."Document Type"::Order,
                        ReservEntry."Source ID",
                        ReservEntry."Source Ref. No.")
                    then begin
                        // Use standard tracking handling here
                        // Do NOT insert Reservation Entries manually
                        // Example:
                        // ItemTrackingMgt.CopyItemTracking(...)
                        // ReservationManagement.UpdateItemTracking(...)
                    end;
                end;
            until ReservEntry.Next() = 0;
    end;

    For Warehouse Shipment Lines:

    • if shipment is not created yet → tracking will normally flow automatically from Sales Line
    • if shipment already exists → tracking may already be copied/static

    In that case you usually need to:

    • delete/recreate Whse. Shipment Line
      OR
    • recreate Warehouse Pick/Shipment

    because warehouse documents do not always dynamically refresh tracking after creation.

    Recommended events to use:

    Table "Reservation Entry"
    OnAfterCopyTrackingFromTrackingSpec
     
    or better:
     
    Codeunit "Item Tracking Management"
     

    or Assembly posting/validation events where BC already updates tracking.

    Main recommendation:

    • Never create tracking for Sales/Whse documents by direct INSERT into table 337
    • Always use Reservation Management / Item Tracking Management codeunits
    • Let BC maintain reservation pairs automatically

    That keeps:

    • order tracking intact
    • warehouse synchronization correct
    • posting logic stable
    • ATO links valid across Sales ↔ Assembly ↔ Warehouse flow
  • Gerardo Rentería García Profile Picture
    27,087 Most Valuable Professional on at
  • Suggested answer
    Grigorios Mavrogeorgis Profile Picture
    2,514 Super User 2026 Season 1 on at
    Hi,
    For propagating Item Tracking from Assembly Order Lines down to Sales Lines and Warehouse Shipment Lines, the event subscriber approach is on the right direction but you may need to handle it differently. Sales Line and Whse. Shipment Line have their own Reservation Entries linked through the source type/subtype/ID structure, so directly inserting new Reservation Entries can create inconsistencies.

    Better approach is to look at codeunit 6500 "Item Tracking Management" in your specific BC version and find the procedures that BC itself use to copy or sync tracking between related documents. The exact function names change between releases, worth open the codeunit in your environment and review what is available before deciding.

    For the link Assembly Order → Sales Line, BC use the "Assemble to Order Link" table (904) to keep these synchronized. So instead of only OnAfterCopyTrackingFromTrackingSpec, you may need to subscribe also on assembly tracking modification events and trigger the proper sync routine.

    Also test carefully with reservation status, Surplus may not be correct if the line is already reserved against the sales order.
     
    ✅ Tick the checkbox below to mark the answer as verified, if it helped resolve your question.
     
    Regards
    Gregory Mavrogeorgis
     

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,222 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,603 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,186 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans