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

Expire trade agreement by x++

(0) ShareShare
ReportReport
Posted on by 143

Hello Everyone,

I have one requirement in which I have to Expire the posted trade agreement by code can some one help me out with code. I'm not sure how to expire trade agreement.

Thanks in advance.

I have the same question (0)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    300,837 Super User 2025 Season 2 on at

    There is a functional support in the standard to get the End date filled on trade agreements. For that reason, I never considered a x++ script myself.

    You can create a new trade agreement journal; retrieve active price agreements with a correction function; edit details and then update by posing the journal.

  • Vishu Beniwal Profile Picture
    143 on at

    Thanks Andre. I'm also doing the same but I'm not sure after posting the new journal with same details, which method to use to update the "To date" in existing line of PriceDiscTable.

  • Verified answer
    Blue Wang Profile Picture
    on at

    Hi Vishu,

    Try this code:

    public static void updateTradeAgreement(PriceDiscAdmTrans priceDiscAdmTrans)
    {
        PriceDiscTable       priceDiscTable;
    
        update_recordSet priceDiscTable
            setting ToDate = priceDiscAdmTrans.FromDate - 1
        where priceDiscTable.AccountCode       == priceDiscAdmTrans.AccountCode
            && priceDiscTable.AccountRelation   == priceDiscAdmTrans.AccountRelation
            && priceDiscTable.ItemRelation      == priceDiscAdmTrans.ItemRelation
            && priceDiscTable.ItemCode          == priceDiscAdmTrans.ItemCode
            && priceDiscTable.Currency          == priceDiscAdmTrans.Currency
            && priceDiscTable.InventDimId       == priceDiscAdmTrans.InventDimId
            && priceDiscTable.UnitId            == priceDiscAdmTrans.UnitId
            && (priceDiscTable.relation          == PriceType::PricePurch || priceDiscTable.relation == PriceType::PriceSales)
            && priceDiscTable.ToDate            == datenull()
            && priceDiscTable.OriginalPriceDiscAdmTransRecId != priceDiscAdmTrans.RecId
            && priceDiscTable.FromDate          != priceDiscAdmTrans.FromDate
            && priceDiscTable.FromDate          < priceDiscAdmTrans.FromDate;
    }

  • Jkingerp Profile Picture
    16 on at

    I was not able to get this x++ to work. I end up receiving an error message in debugging the process where the PriceDiscTable cannot be edited. Has anyone else ran into this?

    pastedimage1672349417915v1.png

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 303 Super User 2025 Season 2

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 157 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

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

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans