web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

update table after purchase order invoice posting

(3) ShareShare
ReportReport
Posted on by 261

Hi Everyone,

I need to update a custom table GRNTable by setting the Status field to "Invoiced" when a Purchase Order is invoice posted in D365 F&O.

Could someone guide me on which method or class I should extend or handle this logic in? Should I use the PurchFormLetter_Invoice class or is there a better place to implement this update after invoice posting?
 

Thanks,

Ayushaman

Categories:
I have the same question (0)
  • Suggested answer
    Saalim Ansari Profile Picture
    648 on at
    update table after purchase order invoice posting

    Hi Ayushaman,

    Just a couple of points to better understand and guide you:

     
    1. Are you using a custom button to post the invoice, or relying on the standard "Invoice" button in the Purchase Order form?

    This will help determine the best place to put your logic.

     
    2. Suggestion:

    If you're using the standard invoice posting process, I recommend adding a toggle checkbox (parameter) either in the PurchParameters or in a custom parameter table.

    That way, your custom logic (updating GRNTable.Status to "Invoiced") will only execute if the toggle is enabled. This approach gives better control and avoids running your logic unnecessarily.

     

    Then, you can safely place your code inside a class extension of PurchFormLetter_Invoice, preferably in the method, with a condition to check the toggle value.

     

    Hope it helps ;) and let me know if you need more help!

  • Martin Dráb Profile Picture
    236,330 Most Valuable Professional on at
    update table after purchase order invoice posting
    You need to clarify what you mean by "a Purchase Order is invoice posted". Most importantly, an order can be invoiced by several partial invoices. Are you interested in the first (partial) invoice or the situation when the order is invoiced in full?
     
    Also note that a credit note can reverse the state of an order from invoiced to open. You need to decide what should happen with your Status field.
  • Ayushaman Profile Picture
    261 on at
    update table after purchase order invoice posting
    Hi Martin,
     
    Thanks for the prompt response.
     
    • Yes, I’m only interested in updating the GRN status when the Purchase Order is fully invoiced. Partial invoices should not trigger the update.
    • The logic should update the GRNTable.Status to "Invoiced" only when the PO reaches the fully invoiced state (i.e., PurchStatus::Invoiced).
    Regarding credit notes:
    As of now, I don’t intend to reverse the GRN status if a credit note is posted. If needed later, I might revisit and enhance the logic accordingly.
    Normally when i PO is invoiced and its status is marked as invoiced that time i have to update the other table which is grntable with status.
  • Ayushaman Profile Picture
    261 on at
    update table after purchase order invoice posting
    Hi @Saalim and @Martin  ,
     
    I thought of a approach like A custom field POInvoicedFlag is added to VendInvoiceJour to indicate that a PO is invoiced. During invoice posting, this flag is set to "Yes". A post-event handler on VendInvoiceJour.insert() checks the flag and PurchId, and if valid, updates the corresponding GRNTable record's status to “Invoiced”.
    Do you guys think its a good approach ?. Also to answer saalim question it is standard invoice button

    Thanks ,
    Ayushaman
     
     
  • Martin Dráb Profile Picture
    236,330 Most Valuable Professional on at
    update table after purchase order invoice posting
    Your solution doesn't meet your requirements. You'd set the flag to Yes when posting a partial invoice, which you said you didn't want.
     
    Maybe you should forget VendInvoiceJour completely. What if you simply override PurchTableType.updateBackStatus() and check whether PurchStatus has changed to Invoiced?
  • Ayushaman Profile Picture
    261 on at
    update table after purchase order invoice posting
    Hi @Martin,
     
    Yes,you are correct for pointing out the issue that will come with partial invoice. As per your suggestion if i use updatebackstatus() from purchtabletype class
    [ExtensionOf(classStr(PurchTableType))]
    final class PurchTableType_WCL_Extension
    {
      public void updateBackStatus()
      {
       
        next updateBackStatus();
    
      
        PurchTable purchTable = this.purchTable(); // i can't directly take a buffer like this 
    
        if (purchTable.PurchStatus == PurchStatus::Invoiced)
        {
          GRNTable grnTable = GRNTable::findByPurchId(purchTable.PurchId, true);
          if (grnTable)
          {
            grnTable.PurchStatus = PurchStatus::Invoiced; 
            grnTable.update();
          }
        }
      }
    }
     how can i get the current purchtable record which i m dealing with ??

    Thanks,
    Ayushaman
  • Anton Venter Profile Picture
    20,301 Super User 2025 Season 2 on at
    update table after purchase order invoice posting
    Is this still an issue for you?
     
     
     
     
     
     
     
     
     
     
     
    Try this or just use purchTable directly.
    PurchTable purchTableLocal = purchTable;
    
    
    
     

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,004

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 582 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans