Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Custom field from Warehouse Receipt to Item Ledger Entries

Posted on by 53
Hi Guys,

I am trying to add a new custom field /TempValQty/ to the Item Ledger Entries table when I post the Warehouse Receipt. This new field is in the Warehouse Receipt Line (7317) table. I have checked the event recorder and don't see the event like  PostItemJnlLine that can be found in codeunit 90 like on other posts.

What I have read is that the values from the Warehouse Receipt runs through a few events/codeunits before it gets to the Item Ledger Entry? I have spent the whole day looking at these events from the event recorder but cannot find the ones responsible for coping the data over to the Item Ledger Entry table.

Can you please assist to give me the correct EventName and Object Name where to find these events so that the new custom field will be added to Item Ledger Entries when I post the Warehouse Receipt?
 
Your assistance is highly appreciated.
 
Divan
  • Custom field from Warehouse Receipt to Item Ledger Entries

    NewtokiIt seems like your question is related to a technical or business process that involves a Warehouse Receipt and Item Ledger Entries. The customization of fields between these two entities might depend on the specific software or system you are using for warehouse management and inventory tracking.

    In general, the customization of fields involves understanding the database schema, programming or configuring changes, and ensuring data consistency. Here's a generic guide on how you might approach this in a database or enterprise system scenario:

  • Suggested answer
    Divan Profile Picture
    Divan 53 on at
    Custom field from Warehouse Receipt to Item Ledger Entries
    Hi @Yun Zhu,

    Thanks for the reply, the source for this
    specific customization will always be a Transfer Order. With the Codeunit::"Whse.-Post Receipt" The event 'OnBeforeValidateQtyToReceiveOnPurchaseLine' is not found in the target and because I am using a Transfer Order as the source and not a Purchase Order I have changed the suggested code below as follow: 


    I have added all the fields as mentioned below except instead of Purchase Line I have added to Transfer Line:

    tableextension 50015 APTRRC_TransferLine extends "Transfer Line"
    {
        fields
        {        field(50003; APTRRC_TempValQty; Decimal)  
          {            Editable = false;
                       Caption = 'Temp Valuation Qty';
                       DataClassification = CustomerContent;
            }
       }
    }

    And changed the events like below:


    In my instance of BC The event 'OnBeforeValidateQtyToReceiveOnPurchaseLine' is not found in the target...

        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Whse.-Post Receipt", 'OnBeforeTransLineModify', '', false, false)]
        local procedure OnBeforeTransLineModify(var TransferLine: Record "Transfer Line"; WhseRcptLine: Record "Warehouse Receipt Line"; var ModifyLine: Boolean; WhseRcptHeader: Record "Warehouse Receipt Header");
        begin
            TransferLine.APTRRC_TempValQty := WhseRcptLine.APTRRC_TempValQty;
        end;

        [EventSubscriber(ObjectType::Codeunit, Codeunit::"TransferOrder-Post Receipt", 'OnBeforePostItemJournalLine', '', false, false)]
        local procedure OnPostItemJnlLineOnAfterCopyDocumentFields(var ItemJournalLine: Record "Item Journal Line"; TransferLine: Record "Transfer Line"; TransferReceiptHeader: Record "Transfer Receipt Header"; TransferReceiptLine: Record "Transfer Receipt Line"; CommitIsSuppressed: Boolean; TransLine: Record "Transfer Line");
        begin
            ItemJournalLine.APTRRC_TempValQty := TransferLine.APTRRC_TempValQty;
        end;

        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", 'OnAfterInitItemLedgEntry', '', false, false)]
        local procedure OnAfterInitItemLedgEntry(var NewItemLedgEntry: Record "Item Ledger Entry"; ItemJournalLine: Record "Item Journal Line"; var ItemLedgEntryNo: Integer);
        begin
            NewItemLedgEntry.APTRRC_TempValQty := ItemJournalLine.APTRRC_TempValQty;
        end;

    Is there a document or some way that I can see what events to use or is the Event Recorder the only way? For example to see "Warehouse Receipt Line"->"Purchase Line"->"Item Journal Line"->"Item Ledger Entry" as this was extremely help full.

    Thanks
    Divan


  • YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 Season 2 on at
    Custom field from Warehouse Receipt to Item Ledger Entries
    The reason why this is more difficult is because when Warehouse Receipt is posted, it is posted to Warehouse Entries, not Item Ledger Entries.
    So this needs to be converted using Purchase Order. (If the source is Purchase Order)
    "Warehouse Receipt Line"->"Purchase Line"->"Item Journal Line"->"Item Ledger Entry"
    So please try the following example:
    codeunit 50115 MyCodeunit2
    {
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Whse.-Post Receipt", OnBeforeValidateQtyToReceiveOnPurchaseLine, '', false, false)]
        local procedure OnBeforeValidateQtyToReceiveOnPurchaseLine(var PurchaseLine: Record "Purchase Line"; WarehouseReceiptLine: Record "Warehouse Receipt Line"; var IsHandled: Boolean);
        begin
            PurchaseLine."ZY Document No." := WarehouseReceiptLine."ZY Document No.";
        end;
    
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch.-Post", OnPostItemJnlLineOnAfterCopyDocumentFields, '', false, false)]
        local procedure OnPostItemJnlLineOnAfterCopyDocumentFields(var ItemJournalLine: Record "Item Journal Line"; PurchaseLine: Record "Purchase Line"; WarehouseReceiptHeader: Record "Warehouse Receipt Header"; WarehouseShipmentHeader: Record "Warehouse Shipment Header"; PurchRcptHeader: Record "Purch. Rcpt. Header");
        begin
            ItemJournalLine."ZY Document No." := PurchaseLine."ZY Document No.";
        end;
    
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", OnAfterInitItemLedgEntry, '', false, false)]
        local procedure OnAfterInitItemLedgEntry(var NewItemLedgEntry: Record "Item Ledger Entry"; var ItemJournalLine: Record "Item Journal Line"; var ItemLedgEntryNo: Integer);
        begin
            NewItemLedgEntry."ZY Document No." := ItemJournalLine."ZY Document No.";
        end;
    }
    
    tableextension 50115 WarehouseReceiptLineExt extends "Warehouse Receipt Line"
    {
        fields
        {
            field(50000; "ZY Document No."; Code[20])
            {
                Caption = 'ZY Document No.';
                DataClassification = CustomerContent;
            }
        }
    }
    
    pageextension 50115 WhseReceiptSubformExt extends "Whse. Receipt Subform"
    {
        layout
        {
            addafter(Description)
            {
                field("ZY Document No."; Rec."ZY Document No.")
                {
                    ApplicationArea = All;
                }
            }
        }
    }
    
    tableextension 50114 PurchaseLineExt extends "Purchase Line"
    {
        fields
        {
            field(50000; "ZY Document No."; Code[20])
            {
                Caption = 'ZY Document No.';
                DataClassification = CustomerContent;
            }
        }
    }
    
    tableextension 50112 ItemJournalLine extends "Item Journal Line"
    {
        fields
        {
            field(50000; "ZY Document No."; Code[20])
            {
                Caption = 'ZY Document No.';
                DataClassification = CustomerContent;
            }
        }
    }
    
    tableextension 50113 ItemLedgerEntryExt extends "Item Ledger Entry"
    {
        fields
        {
            field(50000; "ZY Document No."; Code[20])
            {
                Caption = 'ZY Document No.';
                DataClassification = CustomerContent;
            }
        }
    }
    
    pageextension 50113 MyExtension extends "Item Ledger Entries"
    {
        layout
        {
            addafter("Document No.")
            {
                field("Purch Document No."; Rec."ZY Document No.")
                {
                    ApplicationArea = All;
                }
            }
        }
    }
     
    Test:
     
    Hope this helps.
    Thanks.
    ZHU

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans