Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

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 ?  

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,302 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,114 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans