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

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

(0) ShareShare
ReportReport
Posted on by 3,253

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
    Inge M. Bruvik Profile Picture
    1,111 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
    95,647 Super User 2025 Season 2 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

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,577

#2
YUN ZHU Profile Picture

YUN ZHU 888 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 778 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans