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

Notifications

Announcements

No record found.

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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    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;
        }

     


  • bombtrk Profile Picture
    475 on at

    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?

  • bombtrk Profile Picture
    475 on at

    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);
    }

  • Lauras U Profile Picture
    955 on at

    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)

  • Samy123 Profile Picture
    455 on at

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

  • Menna Allah Ahmed Profile Picture
    163 on at
    I have same problem I need to get itemId and inventDim together , there is anyone have a solution ?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans