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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Display RetailVariantId from InventDimCombination X++

(1) ShareShare
ReportReport
Posted on by 163
I am trying to add new display method in inventDim table 
to display retailvariantid that in table InventDimCombination 
by select InventDimCombination 
where InventDimCombination .InventDimId == inventDim.InventDimId
 
but it Doesn't return anything , but also While using in active method on form (on hand list ) it works correctly but the problem that I need to move for every record to display it right 
 
How can I display variantid on this form ?
I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    Where are you using your code?
     
    And how do you populate inventDim variable? If it's the current record of InventDim data source, than it's not what you want. If you have ten records in a grid and run the method for each of them, the current record of InventDim data source is still the same, therefore the method will return the same value in all cases.
  • Menna Allah Ahmed Profile Picture
    163 on at
    No I put my method in inventDim table 
       public display RetailVariantId VariantId ()
        {
            InventSum InventSum ;
            RetailVariantId Varint ;
            inventDim inventDim;
    	
            InventTable InventTable ;
            InventDimCombination inventDimCombination , InventDimCombination2 ;
        
           select * from InventDimCombination
           where  InventDimCombination.INVENTDIMID == this.inventDimId
           join InventTable
           where InventTable.ITEMID == InventDimCombination.ITEMID;
    
    
           return InventDimCombination.RetailVariantId ;
    	}
    this method doesn't display anything 
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    Let me throw all the unused variables, because these things just make your code harder to understand. The effective code is this:
    public display RetailVariantId variantId()
    {
        InventDimCombination inventDimCombination;
    
        select RetailVariantId from InventDimCombination
            where InventDimCombination.InventDimId == this.InventDimId;
    
        return inventDimCombination.RetailVariantId;
    }
    I see that your code looks for an item combination but it doesn't care about which item it is. It looks like a bug to me, because I can't imagine when this would be useful.
  • Menna Allah Ahmed Profile Picture
    163 on at
    it doesn't work Martin because when I choose two dimensions only by example inventDimId is null but another dimensions have data 
    so I need to pass inventDim only not InventDimId 
     
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    Sure, I'm not saying that there can't more bugs in your solution.
     
    What you're saying sounds like you want to run the method on an unsaved InventDim, which means that InventDimId wasn't assigned or update yet.
     
    But I think you should address the question of ItemId first, because it may show that your overall approach is wrong. It would be a waste of time if you fixed the bug with InventDimId and then threw away the whole thing anyway.
  • Menna Allah Ahmed Profile Picture
    163 on at
        public display RetailVariantId VariantId ()
        {
            InventSum InventSum ;
            RetailVariantId Varint ;
            inventDim inventDim;
    
            InventTable InventTable ;
            InventDimCombination inventDimCombination , InventDimCombination2 ;
      
            InventDimId inventDimIdProductDimensions = InventDimCombination::getInventDimIdForProductDimensions(this);
    
          select RetailVariantId from InventDimCombination
                where InventDimCombination.InventDimId == inventDimIdProductDimensions;
    
           return InventDimCombination.RetailVariantId ;
    	}
    but I need to pass item id also because by passing InventDimId only it gives a wrong values 
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    That's my point.
  • Menna Allah Ahmed Profile Picture
    163 on at
    Okay Martin , That's why I am asking here , how can I get itemID ?
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    Putting a display method on InventDim is wrong, because you have no ItemId there. And as you've accepted, the fact that your code ignores ItemId is a bug.
     
    What we need to do is analyzing your requirements and designing a different solution.
     
    Please tell us which form you're talking about and what you want achieve there. You mentioned an on hand list; don't forget that the usual form for on-hand quantity (such as InventOnhandItem) summarize values based on selected dimensions. If you're working with these forms, you must take this into account.
  • Menna Allah Ahmed Profile Picture
    163 on at
    Yes I am working on InventOnhandItem form I need to display retailVariantId on it also I tried to put this display method on inventSum but InventDimID always null , How can I fix this ?

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 503 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 434 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans