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

I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at

    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.

  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    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
    YUN ZHU Profile Picture
    95,720 Super User 2025 Season 2 on at

    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

  • Eva2020 Profile Picture
    10 on at

    Hello Zhu,

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

    Regards,

    Eva

  • Eva2020 Profile Picture
    10 on at

    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

    Hello Inge,

    We only use one shipment for one invoice.

  • Suggested answer
    Amit Baru Profile Picture
    3,037 on at

    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

    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
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at
    [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.

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 2,664

#2
YUN ZHU Profile Picture

YUN ZHU 960 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans