Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

How to get the cost price displayed on the InventOnHandItem form?

Posted on by 75

I want to display the cost price on my custom form, but the cost price on the InventOnHandItem form is a form level display method, so I can't use it in my custom form directly. How can I get the return value of this display method?

I run the source of this method in debug mode, and the I find that the return value is InventSum.PostedValue / InventSum.PostedQty, but the RecId of the InventSum is 0. I see the data in the table, and find that the value for the same item and inventDim is different from the value got in the debug mode.

  • Verified answer
    bjdchw Profile Picture
    bjdchw 75 on at
    RE: How to get the cost price displayed on the InventOnHandItem form?

    What I want to do is to get the cost price of a specific dimension, so the problem is the cost price values of a same dimension are different.

    The below code seems to work for me.

        InventDim               inventDimCriteria;
        InventDimParm           inventDimParm;
        InventSum               invSum;
        
        inventDimCriteria = InventDim::find('JPMF-000001');
        inventDimParm.initFromInventDim(inventDimCriteria);
        invSum = InventSum::findSum('000001', inventDimCriteria, inventDimParm);
        
        print invSum.costPricePcs();
        pause;


  • Mea_ Profile Picture
    Mea_ 60,274 on at
    RE: How to get the cost price displayed on the InventOnHandItem form?

    As I said before, have you checked dimensions you are using ? because form and class may show them on different level of aggregation.

  • bjdchw Profile Picture
    bjdchw 75 on at
    RE: How to get the cost price displayed on the InventOnHandItem form?

    Hi ievgen Miroshnikov,

    Thank you for your reply. I have used the code in your link for a  test, but the result is different from the InventOnHandItem form.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,274 on at
    RE: How to get the cost price displayed on the InventOnHandItem form?

    RecId is 0 because records on the form are grouped by itemid and inventory dimensions select. You may try something like this to get these values from code dynamicsaxgyan.wordpress.com/.../find-invent-onhand-by-date-dynamics-ax-x but please note it may be slow if you have lots of records in a grid.

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…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans