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

Announcements

No record found.

News and Announcements icon
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,524 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 514 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 390

#3
Adis Profile Picture

Adis 266 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans