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();

}

  • Suggested answer
    Martina123 Profile Picture
    on at
    RE: While select forupdate - Infinite Loop while trying to settle a project invoice more than 200 Lines

    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.

  • Sergei Minozhenko Profile Picture
    23,091 on at
    RE: While select forupdate - Infinite Loop while trying to settle a project invoice more than 200 Lines

    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?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

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... 292,886 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,768 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans