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 :
Supply chain | Supply Chain Management, Commerce
Answered

Purchase Requisition Closed status - X++ Extension

(0) ShareShare
ReportReport
Posted on by 122

Hello everyone,  my goal is to implement COC when the PurchReqTable.RequisitionStatus is equal to "Closed"(I want to implement Chain of Command after the update for PurchReqTable.RequisitionStatus)

I don't know which method or class should I use in order to trace the code. It looks like a background process handles the code when I click the Approve button because
Approve-PR.PNG

after a minute or two the status will be updated from Approved to Closed. I tried the setPurchReqTableByBudgetReservationReference method from  PurchReqWFStatusTransitionHelper class but my code didn't work

[ExtensionOf(classStr(PurchReqWFStatusTransitionHelper))]
final class PurchReqWFStatusTransitionHelper_Extension
{
    public static void setPurchReqTableByBudgetReservationReference(RecId _purchReqTableRecId, boolean _doVersioning)
    {
        next setPurchReqTableByBudgetReservationReference(_purchReqTableRecId, _doVersioning);
        PurchReqRequisitionStatus   toRequisitionStatus;
        toRequisitionStatus = PurchReqTable::evaluateHeaderStatus(_purchReqTableRecId, PurchReqRequisitionStatus::Closed);
        if(toRequisitionStatus == PurchReqRequisitionStatus::Closed)
        {
            info("Closed COC Requisition status");
        }
    }

}

ClosedStatus.PNG

Thanks in advance

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    You could hook in PurchReqTable.update() method.

  • xppdev Profile Picture
    122 on at

    Thank you Nikolaos. Thought my code doesn't work on PurchReqTable.update() I wrote Info on the COC but nothing happened when the status changed to "Closed". But when I tried to insert a record to my own table, it worked like a charm. I found out that the breakpoint does not work if it's executing a background process. But is that really the case? How can I debug it?

  • Martin Dráb Profile Picture
    237,803 Most Valuable Professional on at

    Maybe you're taling about a batch and you haven't attached debugger to to Batch.exe. Please create a new thread (with an appropriate title) if you have more questions not related to the topic of this thread ("Purchase Requisition Closed status - X++ Extension").

    Also, I've noticed you have one more thread about the same thing, namely PurchReqTable - Status Closed (Chain of Command). Next time, please avoid such duplication.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Hi,

    you might confuse two things:

    1) Is my code triggered

    2) Was my breakpoint hit when I'm debugging

    Seems that you tried to debug you CoC code in the update method, and because the breakpoint didn't hit, you think that it's not working. The correct way to figure out if it's working is to look at the result. Did the code do what it was supposed to do?

    As Martin mentioned, in your scenario the process is handled asynchronously by the batch server, so if you debug IIS (normal AOS) the breakpoint won't be hit. But your code still executes. If you need any help with debugging, try to search the web, and post a new question if you have a problem that has not been discussed and solved before.

    Thanks!

  • xppdev Profile Picture
    122 on at

    Thanks Martin. I'll keep that in mind.

  • xppdev Profile Picture
    122 on at

    Hello,

    Yes, I was confused either of that. Thanks for the information. It was a big help for me.

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 > Supply chain | Supply Chain Management, Commerce

#1
Siv Sagar Profile Picture

Siv Sagar 266 Super User 2025 Season 2

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 213 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

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

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans