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...
Suggested answer

Invoice no field should updated when sales invoice posted

(0) ShareShare
ReportReport
Posted on by 10

Hello Experts,

I am developing a program, when a sales invoice is posted then the sales shipment line posted in ILE should get updated with invoice no.

Invoice no. will be a new field in the item ledger entry. I have written program on SalesPost codeunit onafterpost trigger but its not working.

Any suggestions/help would be appriciated.

Thanks,

Eva

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,025 Moderator on at
    RE: Invoice no field should updated when sales invoice posted
    [quote user="Eva2020"]

    Hello Inge,

    We only use one shipment for one invoice.

    [/quote]

    Yes, i understand that. But if i was you i would try to avoid designing a solution that is based on an assumption that your business never will change so you will have several shipments per. invoice or several invoices per. shipment.

    You have all the required information available in the value entries. And when you are at the item ledger entries is just one click away.

  • Eva2020 Profile Picture
    10 on at
    RE: Invoice no field should updated when sales invoice posted

    and in the case of BC On-Prem (CAL), do we just need to add this one line code only to InitItemLedgerEntry function?

    Do i also need to add the new field in ILE and Item Jnl line both?

  • Suggested answer
    Amit Baru Profile Picture
    3,029 on at
    RE: Invoice no field should updated when sales invoice posted

    Hi,

    Pls refer the below code for Reference. In my case i have flow fields in case of purchase.

    [EventSubscriber(ObjectType::Table, Database::"Item Journal Line", 'OnAfterCopyItemJnlLineFromPurchLine', '', False, False)]
        local procedure OnAfterCopyItemJnlLineFromPurchLine(var ItemJnlLine: Record "Item Journal Line";
                        PurchLine: Record "Purchase Line")
        var
        begin
            ItemJnlLine."M.R.P." := PurchLine."M.R.P.";
            ItemJnlLine."Pack Size" := PurchLine."Pack Size";
        end;

        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", 'OnAfterInitItemLedgEntry', '', False, False)]
        local procedure OnAfterInitItemLedgerEntry(var NewItemLedgEntry: Record "Item Ledger Entry";
                                        ItemJournalLine: Record "Item Journal Line")

        var
        begin
            NewItemLedgEntry."M.R.P." := ItemJournalLine."M.R.P.";
            NewItemLedgEntry."Pack Size" := ItemJournalLine."Pack Size";
        end;
    Regards
    Amit Sharma
  • Eva2020 Profile Picture
    10 on at
    RE: Invoice no field should updated when sales invoice posted

    Hello Inge,

    We only use one shipment for one invoice.

  • Eva2020 Profile Picture
    10 on at
    RE: Invoice no field should updated when sales invoice posted

    Hi Zhu,

    as we have one shipment for one invoice, can you please let me know how we can associate this with ILE entry no. Entry no is an Integer field and invoice no( new field) will be a code field

  • Eva2020 Profile Picture
    10 on at
    RE: Invoice no field should updated when sales invoice posted

    Hello Zhu,

    In our case, one shipment will have only one invoice.

    Regards,

    Eva

  • Suggested answer
    YUN ZHU Profile Picture
    82,945 Super User 2025 Season 1 on at
    RE: Invoice no field should updated when sales invoice posted

    Hi, Inge is right.

    There is a situation in the system that one line of Item ledger entries corresponds to multiple invoices.

    For example,

    pastedimage1662537097807v1.png

    pastedimage1662537123021v2.png

    pastedimage1662537132629v3.png

    If you only want to display one invoice No., you can just create a FlowField by associating it with the Item Ledger entry No field.

    pastedimage1662537162110v4.png

    Hope this helps as well.

    Thanks.

    ZHU

  • Suggested answer
    Nitin Verma Profile Picture
    21,546 Moderator on at
    RE: Invoice no field should updated when sales invoice posted

    Hi,

    you can use the below Event from the CU - 80, check with the Item no. you are actually posting through Posted Sales shipment.

        [IntegrationEvent(TRUE, false)]
        local procedure OnAfterPostItemJnlLine(var ItemJournalLine: Record "Item Journal Line"; SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; var ItemJnlPostLine: Codeunit "Item Jnl.-Post Line"; var WhseJnlPostLine: Codeunit "Whse. Jnl.-Register Line"; OriginalItemJnlLine: Record "Item Journal Line")
        begin
        end;
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,025 Moderator on at
    RE: Invoice no field should updated when sales invoice posted

    I think there is a breach in your logic here. Because one invoice is not necessarily the same as one ILE.

    The invoice basically results in a Item Value entry. So to see what invoice are behind a ILE you should look at the value entries, And you can already navigate to them though the ILE page.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 691

#2
YUN ZHU Profile Picture

YUN ZHU 646 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 495

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans