Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

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

Posted on by 440

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
    Martina123 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
    Sergei Minozhenko 23,089 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans