Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / Update of PurchTable n...
Finance forum
Unanswered

Update of PurchTable not triggered when all order lines are deleted

Posted on by 18
Hi, I'm trying to do a customization, the scenario is as follows:
I want to update a custom field whenever the Purch status of PurchTable is changed to Cancel or the document status is changed to Confirmed. I've implemented it in the following form, that whenever the status value of PurchTable is changed and it is one of the two conditions the field value gets updated. But the update event on PurchTable is triggered only for the case of Confirm, for the Cancel condition the update event is not triggered.
 
[Extensionof(tablestr(PurchTable))]
public final class vsiJNIPurchExpectedArrival_Extension
{
    public void update(boolean _updateDistributions)
    {
        PurchTable purchTable_orig = this.orig();

        if((this.PurchStatus != purchTable_orig.PurchStatus) || (this.DocumentState != purchTable_orig.DocumentState))
        {
            if((this.PurchStatus == PurchStatus::Canceled && this.DocumentState != VersioningDocumentState::Confirmed)
                || (this.PurchStatus != PurchStatus::Canceled && this.DocumentState == VersioningDocumentState::Confirmed))
            {
                this.vsiJNIPOExpectedArrival = NoYes::Yes;
            }
            else
            {
                this.vsiJNIPOExpectedArrival = NoYes::No;
            }
        }

        next  update(_updateDistributions);
    }

}
 
  • Martin Dráb Profile Picture
    Martin Dráb 228,366 Most Valuable Professional on at
    Update of PurchTable not triggered when all order lines are deleted
    You can use the debugger to find out what happens in code.
     
    You mentioned that you're interested in the scenario when then last purchase order line is deleted, therefore you can put a breakpoint to PurchLine.delete() and check its behavior.
     
    I would start with the call of purchTable.updateStatusFromPurchLines() (line 2940 in my application). Check whether it gets called at all; there are conditions that prevent it (e.g. if isDelayUpdating() returns true).
     
    (Moved from Dynamics AX forum.)

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,462 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,366 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans