web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
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

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    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.

  • bjdchw Profile Picture
    75 on at

    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.

  • Mea_ Profile Picture
    60,286 on at

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

  • Verified answer
    bjdchw Profile Picture
    75 on at

    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;


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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans