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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

How to calculate Invoice discount on sales orders

(0) ShareShare
ReportReport
Posted on by 73
Hello All, I want to calculate invoice discount when creating sales orders through customization.I have written below code to update /Invoice discount/ field on sales orders but its not working. Can anyone suggest how to update invoice discount after creating sales orders.
 
 
        //To update invoice discount++
        SalesHeader2.Reset();
        SalesHeader2.SetRange(/External Document No./, LocationGUID);
        if SalesHeader2.FindSet() then begin
            repeat
                OrderDiscountAmt1 := 0;
                SalespossierBridge5.Reset();
                SalespossierBridge5.SetRange(/Sales Order No./, SalesHeader2./No./);
                SalespossierBridge5.SetFilter(Discount_discounts, '<>%1', '');
                if SalespossierBridge5.FindSet() then begin
                    repeat
                        Evaluate(OrderDiscountAmt, SalespossierBridge5.Discount_discounts);
                        OrderDiscountAmt1 += OrderDiscountAmt;
                    until SalespossierBridge5.Next() = 0;
 
                    SalesHeader2./Invoice Discount Calculation/ := SalesHeader2./Invoice Discount Calculation/::Amount;
                    SalesHeader2./Invoice Discount Value/ := OrderDiscountAmt1;
                    SalesHeader2.Modify();
 
                end;
            until SalesHeader2.Next() = 0;
        end;
        //
I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,218 Super User 2026 Season 1 on at
    What value do you have in LocationGUID?
    Is that same value is there in External Document No. field of Sales Header?
    Please add messages in some places and check whether your code is hitting those places or not.
    Or better to debug.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#2
YUN ZHU Profile Picture

YUN ZHU 1,351 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,200 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans