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

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
    60,993 Super User 2025 Season 2 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

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 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans