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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Performance Issue caused when overriding sales tax on each sales order line through x++ code

(1) ShareShare
ReportReport
Posted on by 12
Hello Users,
 
I am overriding posted sales tax value on line level using below code:
 
private void taxCalcLine(SalesTable _salesTable, SalesLine _salesLine, real _salesTax)
    {
        TaxTmpWorkTransForm                taxTmpWorkTransForm ;
        SalesTotals                        salesTotals;
        TmpTaxRegulation                   tmpTaxRegulation, tmpTaxRegulation2;
        TmpTaxWorkTrans                    tmpTaxWorkTrans;
        TransDate                          localDateOfVATRegister;
        CurrencyExchangeRate               localSalesTaxExchangeRate;
        TaxRegulationDetail                taxRegulationDetail;
        int                                salesTaxCodes;
        SalesParmTable                     salesParmTable;
        TaxRegulation                      taxRegulation;
 
        
        salesTotals = SalesTotals::construct(_salesTable);
        salesTotals.calc();
 
        taxRegulation = TaxRegulation::newTaxRegulation(SalesTotals.Tax(), null, tableNum(SalesLine), _salesLine.RecId);
        tmpTaxRegulation2 = TaxRegulation.tmpTaxRegulationDetail();
  
        taxRegulation.updateTaxRegulationAmount(tmpTaxRegulation2,_salesTax,true);
        TaxRegulation.saveTaxRegulation();
    }
 
This code is updating the default sales tax value in the sales order with the _salesTax value provided by us. However I am using this following code in multithreaded approach and this code is impacting the performance of batch job.
Without overriding the sales tax the batch job takes around 9 mins but for the same data and the overriding code the batch job takes around 21 mins.
 
Is there any alternative approach for overriding the sales tax which can improve batch job performance ?  
I have the same question (0)
  • Suggested answer
    Raj Borad Profile Picture
    1,434 on at
    Hi Tanay,
     
    Instead of overriding the sales tax on each line, you can create a new line with total of sales tax of all lines and insert it into the sales order.
    This will also help to reduce the batch job run time.
     
    Thanks.
    Raj

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 471 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 423 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans