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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Copy Sales Order Quantity to Posted Sales Invoice Line - Event to subscribe

(0) ShareShare
ReportReport
Posted on by 3,315

Hi All

I'm trying to copy sales order (original) quantity to posted Invoice line user field. This is to calculate back order quantity and show on posted invoice. The event below did not work:

[EventSubscriber(ObjectType::Codeunit, 80, 'OnAfterSalesInvLineInsert', '', false, false)]
Looks like SO gets deleted before this event
Is there any other event I can use
Thanks
I have the same question (0)
  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    I would recommend you to try the "OnBeforeSalesInvLineInsert" event in the same codeunit.

    Butif there is a back order quantity on the line the sales line should anyway not be deleted?

    Only sales lines that are fully invoiced will be deleted during post.

  • Verified answer
    YUN ZHU Profile Picture
    101,458 Super User 2026 Season 1 on at

    Hi, try the follwoing.

    tableextension 80122 MyExtension extends "Sales Invoice Line"
    {
        fields
        {
            field(50100; OrigianlQuantity; Decimal)
            {
                DataClassification = CustomerContent;
            }
        }
    }
    
    pageextension 80122 MyExtension extends "Posted Sales Invoice Subform"
    {
        layout
        {
            addafter(Quantity)
            {
                field(OrigianlQuantity; Rec.OrigianlQuantity)
                {
                    ApplicationArea = All;
                }
            }
        }
    }
    
    codeunit 80122 MyCodeunit
    {
    
        Permissions = tabledata "Sales Invoice Line" = rimd;
    
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnAfterPostSalesLine', '', false, false)]
        local procedure OnAfterPostSalesLine(var SalesLine: Record "Sales Line"; var SalesInvLine: Record "Sales Invoice Line");
        begin
            SalesInvLine.OrigianlQuantity := SalesLine.Quantity;
            SalesInvLine.Modify();
        end;
    }

    pastedimage1642984075582v2.png

    pastedimage1642984096164v3.png

    Hope this will help.

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April 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,216 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,471 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,369

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans