Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / PriceDiscTable::find()...
Finance forum

PriceDiscTable::find() returns expired price

(0) ShareShare
ReportReport
Posted on by 6,603

Hello,

We have some custom code which pulls the trade agreement price for a specific account relation using PriceDiscTable::find(...). The PriceDiscTable table does show there are two prices for the item, account relation, inventdim, etc with one of the record no longer active based on ToDate. However, find() will pull the inactive price every time. The base code for PriceDiscTable::find() states it will be deprecated. I'm curious if anyone has had this issue and can offer a solution?

Thank you!

  • Pedro Tornich Profile Picture
    Pedro Tornich 955 on at
    RE: PriceDiscTable::find() returns expired price

    You're welcome!

    If my answer helped you in any way, please consider marking it as verified to help other community members.

  • bankk Profile Picture
    bankk 6,603 on at
    RE: PriceDiscTable::find() returns expired price

    Hi Andre,

    The issue seems to be that there is no date being passed to the call to find(). The find() method used firstOnly in its query but I'm not sure how the order is determined and if there is a reference to a date being passed.

    PriceDiscTable::find(PriceType::PriceSales, TableGroupAll::Table, _itemId, TableGroupAll::GroupId, _priceGroup, inventDimItem, unitId, 'USD',0).Amount;

    Thank you.

  • bankk Profile Picture
    bankk 6,603 on at
    RE: PriceDiscTable::find() returns expired price

    Hi Pedro,

    I tested out your example but ran into errors. I found out that in D365FO I have to build a PriceDiscParameter and feed it to PriceDisc. It appears to work fine. I'm also looking into querying the PriceDiscTable directly as an option.

    Thank you so much!

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,431 Super User 2024 Season 2 on at
    RE: PriceDiscTable::find() returns expired price

    Hi ichiban,

    Did you verify if the custom code is correct? Note that an old delivery date might also be retrieving older prices.

  • Verified answer
    Pedro Tornich Profile Picture
    Pedro Tornich 955 on at
    RE: PriceDiscTable::find() returns expired price

    Hi Ichiban,

    The PriceDiscTable is not a Valid Time State Table, which means that it will not filter the active records automatically.

    To find prices use the PriceDisc class.

    Here is a sample code, you may change the module and the parameters according to your needs:

    public Price findPurchPrice(ItemId _itemId, VendTable vendTable, InventDim _inventDim, Qty _qty)
    {
    Price price;
        PriceDisc priceDisc = new PriceDisc(
    ModuleInventPurchSales::Purch,
    _itemId,
    _inventDim,
    InventTable::find(_itemId).inventTableModuleInvent().UnitId,
    DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()),
    _qty,
    vendTable.AccountNum);

    if (priceDisc.findPrice(vendTable.PriceGroup))
    {
    price = priceDisc.price();
    }
    else(priceDisc.findItemPrice())
    {
    price = priceDisc.price();
    }

    return price;
    }

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans