web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Custom fields from Purchase order to Item Ledger Entries

(0) ShareShare
ReportReport
Posted on by 54

Hello

I want to add PO number in Item Ledger Entry when we post the PO. In Item ledger entry there is an Order no. field but it is empty in case of sales order and Purchase order.

Any suggestion on how I can bring PO number in Item ledger Entry

pastedimage1680867014650v1.png

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,331 Super User 2025 Season 2 on at

    Hi, If you are posting from a PO, the easier way is to add a FLowField, I hope the information below can give you some hints.

    pastedimage1681087419110v2.png

    pastedimage1681087424944v3.png

    pastedimage1681087433954v4.png

    pastedimage1681087466796v5.png

    pastedimage1681087479089v6.png

    Thanks.

    ZHU

  • UserRecord Profile Picture
    54 on at

    Hello

    Thank you for the suggestion!

    However, I am looking for saving the field in table. Any codeunit which I can subscribe?

  • Suggested answer
    Shawnsauve Profile Picture
    1,093 on at

    To add the PO number to the Item Ledger Entry when posting a Purchase Order, you need to modify the Item Journal Template that's used for posting the Purchase Order Receipt. Here are the steps to follow:

    1. Open the Item Journal Template: Navigate to the Item Journal Templates page and select the template that's used for posting the Purchase Order Receipt.

    2. Add the PO number field to the template: On the Item Journal Line FastTab, click the "Edit" button to modify the fields on the journal line. Add the "Document Type" field, set it to "Purchase Order", and add the "Document No." field next to it.

    3. Assign the template to the Purchase Order Receipt: In the Purchase Order Receipt page, go to the "Navigate" tab, select "Posting", and then select "Item Journal Templates". Select the Item Journal Template that you modified in step 2 and assign it to the Purchase Order Receipt.

    4. Post the Purchase Order Receipt: Fill in the required information on the Purchase Order Receipt, including the PO number, and then post the receipt. The PO number should now appear in the "Document No." field in the Item Ledger Entry.

    Note: These steps are specific to adding the PO number to the Item Ledger Entry when posting a Purchase Order Receipt. If you want to add the PO number for sales orders, you will need to modify the Item Journal Template used for posting sales transactions.

  • Verified answer
    YUN ZHU Profile Picture
    95,331 Super User 2025 Season 2 on at

    Hi, This is a two-step process because the "Item Ledger Entries" values come from the "Item Journal Line", so you must first add the field to the "Item Journal Line" and pass the values there, and then pass the values to the Item Ledger Entries when you post the "Item Journal Line"

    codeunit 50112 MyCodeunit
    {
        [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."Purch Document No." := PurchaseLine."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."Purch Document No." := ItemJournalLine."Purch Document No.";
        end;
    }
    
    tableextension 50112 MyExtension extends "Item Journal Line"
    {
        fields
        {
            field(50000; "Purch Document No."; Code[20])
            {
                Caption = 'Purch Document No.';
                DataClassification = CustomerContent;
            }
        }
    }
    
    tableextension 50113 MyExtension2 extends "Item Ledger Entry"
    {
        fields
        {
            field(50000; "Purch Document No."; Code[20])
            {
                Caption = 'Purch Document No.';
                DataClassification = CustomerContent;
            }
        }
    }
    
    pageextension 50113 MyExtension extends "Item Ledger Entries"
    {
        layout
        {
            addafter("Document No.")
            {
                field("Purch Document No."; Rec."Purch Document No.")
                {
                    ApplicationArea = All;
                }
            }
        }
    }

    Test:

    pastedimage1681108924508v1.png

    pastedimage1681108931247v2.png

    Item Ledger Entries:

    pastedimage1681108957974v3.png

    Hope this helps.

    Thanks.

    ZHU

  • aryaps Profile Picture
    155 on at

    its superb.

    if we want to bring posted sales invoice number also there how it will be. right now for entry type sales, Posted sales shipment number which means delivery note number is coming as EDN. so next to it

    how can we bring postesd sales invoice number if entry type is sales then posted sales inv and if entry type is purchase then pur order number

    ilee.jpg

  • Suggested answer
    YUN ZHU Profile Picture
    95,331 Super User 2025 Season 2 on at

    Hi, It is not recommended to do this, because there is a one-to-many situation in the system.

    For example,

    Post Ship first in the Sales order.

    pastedimage1681288704350v1.png

    pastedimage1681288718627v2.png

    Then use Get Shipment Lines... in the sales invoice to post in two invoices.

    pastedimage1681288766583v3.png

    pastedimage1681288775705v4.png

    pastedimage1681288788249v5.png

    pastedimage1681288815005v6.png

    pastedimage1681288824254v7.png

    In this way, when you click Sales Amount in Item Ledger Entries, you will find that there will be two invoices with different invoice numbers.

    pastedimage1681288951464v8.png

    pastedimage1681288959816v9.png

    Not only in this case, for example, when there is an Item Charge, or when the cost is adjusted, new Value Entries will also be generated, so I personally do not recommend this.

    Hope this helps.

    Thanks.

    ZHU

  • aryaps Profile Picture
    155 on at

    Okay thanks for Detail Reply Zhu.

    is there any other option to achieve those result in item led entry.

    right now its very difficult to go inside each time and check the details.

  • Suggested answer
    YUN ZHU Profile Picture
    95,331 Super User 2025 Season 2 on at

    Emmm, the easiest way is to use Flowfield. In fact, the standard Sales Amount does the same.

    For example, for Sales, you can add a Count in addition to the Invoice number. If it is not 1, you can click to confirm whether there are multiple invoices.

    tableextension 50112 MyExtension2 extends "Item Ledger Entry"
    {
        fields
        {
            field(50100; InvoiceNumber; Code[20])
            {
                Caption = 'Sales Invoice Number';
                FieldClass = FlowField;
                CalcFormula = lookup("Value Entry"."Document No." where("Item Ledger Entry No." = field("Entry No."), "Document Type" = const("Sales Invoice")));
            }
    
            field(50101; InvoiceCount; Integer)
            {
                Caption = 'Sales Invoice Count';
                FieldClass = FlowField;
                CalcFormula = count("Value Entry" where("Item Ledger Entry No." = field("Entry No."), "Document Type" = const("Sales Invoice")));
            }
        }
    }
    
    pageextension 50113 MyExtension extends "Item Ledger Entries"
    {
        layout
        {
            addafter("Item No.")
            {
                field(InvoiceNumber; Rec.InvoiceNumber)
                {
                    ApplicationArea = All;
                }
                field(InvoiceCount; Rec.InvoiceCount)
                {
                    ApplicationArea = All;
                }
            }
        }
    }

    pastedimage1681292620980v1.png

    Hope this helps.

    Thanks.

    ZHU

  • aryaps Profile Picture
    155 on at

    Thankyou soo much for your time and response.

    just one more query, if there is two invoices count will be shown only like 2, 3 etc .we have to go and check what will be other number. pls correct if i understood is wrong.

    if am wrong could pls add some screenshots pls..

    i really appreciate your kind support

  • Suggested answer
    YUN ZHU Profile Picture
    95,331 Super User 2025 Season 2 on at

    Yes, because using Flowfield, only one invoice number can be displayed. According to my practice, click on the number behind to view all invoice numbers.

    pastedimage1681293782886v1.png

    pastedimage1681293794196v2.png

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans