Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

X++ - Updating Discount Terms On PurchTable not Recalculate Discount

(0) ShareShare
ReportReport
Posted on by 95

Hi

I have an X++ method that will update a PO's discount terms.

When I call the Update or doUpdate method on PurchTable for that PO and look back in the PO screen in AX - I do not see anything changed for that PO Header (after refresh) - the discount term is still blank (thus discount amount etc. hasn't been calculated)?

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ - Updating Discount Terms On PurchTable not Recalculate Discount

    Considering writing code like this

    ttsbegin;

    purchTable = PurchTable::find(myPurchId, true); // for upadte

    if (purchTable.PurchId) // found PO

    {

      purchTable.Payment = myValidPaymentTerm; // e.g. N030

      purchTable.CashDisc = myValidDiscountTerm; // e.g 4%D10

      //Call method to calculate the Discount amount

      purchTable.Update(); // I have also tried "doUpdate()" - but nothing calculated

    }

    ttscommit;

    Please verify and update with your finidngs

  • DAX09 Profile Picture
    DAX09 2,470 on at
    RE: X++ - Updating Discount Terms On PurchTable not Recalculate Discount

    Hi All

    I am using AX12(R2). Slimmed down snippet of code below:

    purchTable = PurchTable::find(myPurchId, true); // for upadte

    if (purchTable.PurchId) // found PO

    {

       purchTable.Payment = myValidPaymentTerm; // e.g. N030

       purchTable.CashDisc = myValidDiscountTerm; // e.g 4%D10

       ttsbegin;

       purchTable.Update(); // I have also tried "doUpdate()" - but nothing calculated

       ttscommit;

    }

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ - Updating Discount Terms On PurchTable not Recalculate Discount

    Can you please post the X++ methods code snippet to understand how you are updating the record.

    normally discount term field should  get updated.

    for discount amount may be you need to check if you have called the logic which will calculate the amount and assign the value to the relevant field.

    Please verify and update with your findings.

  • dolee Profile Picture
    dolee 11,279 on at
    RE: X++ - Updating Discount Terms On PurchTable not Recalculate Discount

    Hi,

    - Which version of AX you are on?

    - Have you try Ctrl-F5?

    - Have you check the backend DB, is the record updated?

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,514 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans