Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

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

(0) ShareShare
ReportReport
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.

*This post is locked for comments

  • 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,278 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,278 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.

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! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans