Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

InventSum - blank InventDimID x++

(0) ShareShare
ReportReport
Posted on by 475

I'm new to x++ so I'm trying pick this up as I go.

I duplicated the InventOnHandItem form so that I can have customized copy.

I've learned that I won't be able to get the InventDimID from a method on the form because the data is summed.

I figured I could create a method on InventSum to return data that I want. I want to create a field that goes to InventTrans and sums the qty based on ItemID and InventDimID...

display Qty physicalReservedNT()
{

    InventTrans     _inventTrans;
    ;

    select sum(qty) from _inventTrans
            index DimIdIdx
            group by _inventTrans.ItemId, _inventTrans.inventDimId
            where _inventTrans.StatusIssue   == Statusissue::ReservPhysical &&
                  _inventTrans.TransType     == InventTransType::InventTransfer &&
                  _inventTrans.ItemId        == this.ItemId &&
                  _inventTrans.inventDimId   == this.InventDimId;


    return abs(_inventTrans.Qty);

    //return this.availOrdered();
}

 

When I step through the code, the InventDimID is blank for any item I use. From the InventSum table methods, how can I get InventDimID?

*This post is locked for comments

  • Menna Allah Ahmed Profile Picture
    163 on at
    InventSum - blank InventDimID x++
    I have same problem I need to get itemId and inventDim together , there is anyone have a solution ?
  • Samy123 Profile Picture
    455 on at
    RE: InventSum - blank InventDimID x++

    Any luck bombtrk? I am also in a similar situation. InventDimId always blank how to get the values in InventDimId.  

  • Lauras U Profile Picture
    955 on at
    Re: InventSum - blank InventDimID x++

    I have similar problem.

    community.dynamics.com/.../87175.aspx

    I found two people reporting, that they manage to cope with this kind of problem by writing display methods directly on table. But I didn`t have luck on this...

    One example (taken from objectmix.com/.../788694-display-method-2-datasources-input.html) of geting configId on this form:

    >You can get all the info from InventSum.

    Create a new display method on InventSum table.

    You will get the ItemId from InventSum directly, and you can get ConfigId

    from InventDim, which you can get through InventSum, for example like the

    following

    (assuming this is a method on InventSum table, as I suggested above):

    ConfigTable::find(this.ItemId, this.inventDim().ConfigId)

  • bombtrk Profile Picture
    475 on at
    Re: InventSum - blank InventDimID x++

    This is what I have so far. It's on the InventSum table. I want to go and sum up data from InventTrans without Transfers.

    I can get the InventOnHandItem form to display this field, but when I step through the code, the InventDimID is blank. Why is that? What am I missing?

     

    //BP Deviation documented
    display Qty physicalReservedNT()
    {

        InventTrans     _inventTrans;
        InventSum       _inventSum;
        InventDim       dim;
        ;

        if(!this.InventDimId)
        {
            dim = InventDim::findDim(this.inventDim());
            if(dim.InventDimId)
                _inventSum.InventDimId = dim.InventDimId;
        }


        select sum(qty) from _inventTrans
                index DimIdIdx
                group by _inventTrans.ItemId, _inventTrans.inventDimId
                where _inventTrans.StatusIssue   == Statusissue::ReservPhysical &&
                      _inventTrans.TransType     != InventTransType::InventTransfer &&
                      _inventTrans.ItemId        == this.ItemId &&
                      _inventTrans.inventDimId   == dim.inventDimId;


        return abs(_inventTrans.Qty);
    }

  • bombtrk Profile Picture
    475 on at
    Re: InventSum - blank InventDimID x++

    I've tested this code from the InventSum table and the InventOnHandItem form but when I step through the code, the InventDimID is always blank...

    What am I missing here?

  • Suggested answer
    Community Member Profile Picture
    on at
    Re: InventSum - blank InventDimID x++

    Hi,

    You can write a display method on the form's datasource level but the problem with doing that is the active record is only calculated.  As soon as you switch off the active record, the display method is recalculated and displayed.

    So if you have two warehouses with on hand qty for an item, the following display method will work for the active record within the InventOnHandItem form.


     

    Try putting this check in your inventSum table display method:

     if(!_inventSum.InventDimId)
        {
            dim = InventDim::findDim(this.inventDim());
            if(dim.InventDimId)
                _inventSum.InventDimId = dim.InventDimId;
        }

     


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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
Zain Mehmood Profile Picture

Zain Mehmood 6 Moderator

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans