Does anyone know how to get the name of a product from EcoResProduct on Dynamics ax on a Job?
I found some things like I have to use the EcoResProductTraslation, but I cant find the relation or something to get the name.
2 Answers
The method InventTable.productName() might be useful for your purpose. The method finds a product variant that is based on the value of the _inventDimId parameter. If the product variant is found then its name is returned; otherwise, the name of a product that this item represents is returned. Please check the example below:
InventTable inventTable; EcoResProduct ecoResProduct; EcoResProductName productName; ; inventTable = InventTable::find('AnyItemId'); productName = inventTable.productName(SystemParameters::getSystemLanguageId()); info(productName); ecoResProduct = EcoResProduct::find(inventTable.Product); productName = ecoResProduct.productName(); info(productName); You can investigate the code of function to understand what it actually does. Also you can use cross references to find examples where it is used.
2The data structure is indeed a bit tricky, but thankfully AX standard already has a display method that does the heavy lifting for you: EcoResProduct.displayProductName()