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

Community site session details

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

Issue carrying modified sales lines to posted sales invoice lines

(1) ShareShare
ReportReport
Posted on by 2
Hello All,
 
I am currently working on a solution that entails changing the OOB /Line Amount/ field to adjust based off of commission %. This amount is modified correctly on the sales lines, however when I preview the sales order posting, or post the sales order - the adjusting line value /Line Amount/ Changes back to what it was prior to the modification.
 
I have been looking through the sales-post code unit trying to use integration events to no-avail , has anyone worked with anything of this nature before that could offer solutions on how to take the current values from the sales lines to the G/L Entries and Posted Sales invoice lines. Rather than them recalculating the base values?
 
TIA!
 
Here are the values I'm modifying on the sales line when commission % is modified - 
I want these changed values to carry over to the Posted Sales Invoice Lines.
modify(/GCB Commission %/)
        {
            Trigger OnAfterValidate()
            begin
                if /GCB Commission %/ = 0 then begin
                    /Rep Order Amount/ := 0;
                    /Line Amount/ := /Unit Price/ * /Quantity/;
                    /Amount Including VAT/ := /Line Amount/ + (/Line Amount/ * /VAT %/ / 100);
                    /Amount/ := /Unit Price/ * /Quantity/;
                    /VAT Base Amount/ := /Line Amount/ + (/Line Amount/ * /VAT %/ / 100);
                    /Outstanding Amount/ := /Line Amount/ + (/Line Amount/ * /VAT %/ / 100);
                    /Outstanding Amount (LCY)/ := /Line Amount/ + (/Line Amount/ * /VAT %/ / 100);
                    // /Amount Including VAT/ := /Line Amount/ + (/Line Amount/ * /VAT %/ / 100);
 
                end
                else begin
                    /Rep Order Amount/ := /Quantity/ * /Unit Price/;
                    /Line Amount/ := (/Unit Price/ * /Quantity/) * (/GCB Commission %/ / 100);
                    /Amount Including VAT/ := /Line Amount/ + (/Line Amount/ * /VAT %/ / 100);
                    /Amount/ := (/Unit Price/ * /Quantity/) * (/GCB Commission %/ / 100);
                    /VAT Base Amount/ := /Line Amount/ + (/Line Amount/ * /VAT %/ / 100);
                    /Outstanding Amount/ := /Line Amount/ + (/Line Amount/ * /VAT %/ / 100);
                    /Outstanding Amount (LCY)/ := /Line Amount/ + (/Line Amount/ * /VAT %/ / 100);
 
                end;
            end;
        }
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    93,889 Super User 2025 Season 2 on at
    Issue carrying modified sales lines to posted sales invoice lines
    Hi, please do not use the assignment operator (:=), use the following method. Some key fields are hidden in the table and will change along with the validation of other fields. However, if you only use the assignment operator, the code in the field validate trigger will not be executed. This should be the problem.
    Record.Validate(Any [, Any]) Method
     
     
    Hope this helps.
    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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,225

#2
Sumit Singh Profile Picture

Sumit Singh 2,123

#3
YUN ZHU Profile Picture

YUN ZHU 1,813 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans