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

While select forupdate - Infinite Loop while trying to settle a project invoice more than 200 Lines

(0) ShareShare
ReportReport
Posted on by 446

Hi,

We have MS Dynamics AX 2012 R3, We are trying to settle a project invoice that contains more than 200 lines.

Unfortunately, while trying to settle the invoice the system is hanging. We tried to debug the code then we found that the code is looping into a specific method.

Class\CustVoucher\updateProjTransPosting

This method contains a while loop that 'select for update' and 'insert' new records into 'projTransPosting' table. If we tried to settle any other invoice that contains a fewer number of lines, it is working normally.

I tried the following URL by using "RecordInsertList" but unfortunately I still have the same issue.

https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/289490/infinite-loop/1046427#1046427

Class\CustVoucher\updateProjTransPosting

    while select forupdate projTransPostingOrig
        where projTransPostingOrig.Voucher == _voucherNo &&
              projTransPostingOrig.PaymentStatus == ProjPaymentStatus::ExpectedPayment
    {
    
        // Check to see if the partial payment needs to be done
        if (_partialPayment)
        {
            // Copy the row to be inserted
            ProjTransPostingInsert.data(projTransPostingOrig);


            // Copy the original amount and qty
            originalQty    = projTransPostingOrig.Qty;
            originalAmount = projTransPostingOrig.AmountMst;

            // get percentage of partial payment
            partialAmount = Currency::amount(originalAmount * _percentagePayment);
            partialQty = decRound(originalQty * _percentagePayment, 2);

            // insert new record
            ProjTransPostingInsert.AmountMst     = originalAmount - partialAmount;
            ProjTransPostingInsert.Qty           = originalQty - partialQty;
            ProjTransPostingInsert.PaymentStatus = ProjPaymentStatus::ExpectedPayment;

            projTransPostingInsert.insert();

            // We need to edit the existing record to reflect the partial payment
            projTransPostingOrig.AmountMst =  partialAmount;
            projTransPostingOrig.Qty =  partialQty;
        }


        projTransPostingOrig.PaymentStatus = _paymentStatus;
        projTransPostingOrig.PaymentDate = _paymentDate;
        projTransPostingOrig.update();

}

I have the same question (0)
  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Peter,

    Have you checked how many records you have in ProjTransPosting for a certain voucher? Do you see if the mentioned loop is the reason for long processing or system executes CustVoucher::updateProjTransPosting again and again?

  • Suggested answer
    Martina123 Profile Picture
    on at

    Hi Peter,

    Do you have any customization for this process? If not, I would recommend that you raise a support ticket to Microsoft, since performance issue could be complex, and it takes time to troubleshoot.

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans