Skip to main content

Notifications

Microsoft Dynamics AX forum
Suggested answer

Add existing product category, product attribute and product attribute value to a product with x++

Posted on by 1,080

Hi there!

I'm having some issues trying to "set" an existing Category Hierarchy, Category, Product Attribute and Product attribute value in X++ at the moment I create a new ecoResProduct record.

I have the product created and released to AX, I just need to set these values automatically. In addition, I also know how to get these values (http://axwonders.blogspot.com/2013/01/get-product-attribute-values-in-ax-2012.html) but I just can't set them at run time.

I have tried to insert independent pieces of records to the following tables:

EcoResValue (The recId of the existing attribute value, Instance Rel Type and Rel type)

EcoResValueAttribute (Value = the EcoResValue Rec Id and a fix attribute and the rec id of he InventTable rel type)

The above does not work and somehow the data is not reflected in the view EcoResProductAttribute value, which I think is th responsible for displaying the correct relationship of categories and product attributes.

Is anyone doing this? If so, would it be possible to get some sample code for it?

Thanks a lot!

 

  • Suggested answer
    Kauto Profile Picture
    Kauto 2,650 on at
    RE: Add existing product category, product attribute and product attribute value to a product with x++

    Hi All

    For anyone that is interested we had the same issue and I tracked it down to not having a relationship created in EcoResCategoryAttribute table for that Attribute RECID and the parent product Category - just one record here with modifier set to Category was enough to resolve as the data view EcoResProductAttribute had the relationship records successfully created

  • Eben Abraham Profile Picture
    Eben Abraham 10 on at
    RE: Add existing product category, product attribute and product attribute value to a product with x++

    Hi EduardoAndres ,

    Were you able to add attribute and its attribute values to a product through code? If yes can you please let me know how did you do it.

    Thanks

  • Florian Hopfner Profile Picture
    Florian Hopfner 2,440 on at
    Re: Add existing product category, product attribute and product attribute value to a product with x++

    Hi,

    please note that you can only add values to an attribute, not a category. To create a relationship between a product and an attribute, you would first have to create a relationship in table EcoResProductCategory between the product and a category and then a relationship between the category and the attribute in table EcoResCategoryAttribute.

    Take into consideration that method init of data source EcoResCategory in form EcoResAttributValue filters the available attributes to those of procurement (and retail, if you have installed Feature Pack) category hierarchies.

    Best regards

    FH

  • EduardoAndres Profile Picture
    EduardoAndres 1,080 on at
    Re: Add existing product category, product attribute and product attribute value to a product with x++

    Thanks for the reply. I have looked at those methods and basically what they do is "add" a new value to a category and/or product attribute, but theydo not create the relationship between product and attributes that I'm looking for.

    Thanks again.

  • Florian Hopfner Profile Picture
    Florian Hopfner 2,440 on at
    Re: Add existing product category, product attribute and product attribute value to a product with x++

    Hi,

    you could take a look at form EcoResAttributeValue and the logic in the methods there, especially createValue und attributeChanged to get an idea how to create these records.

    Other than that I assume your problem is with the attribute values and you are able to create the other records to associate a category from a category hierarchy to a product and associate product attributes. Please also note that not all category hierarchy roles support product attributes.

    Best regards

    FH

Helpful resources

Quick Links

Dynamics 365 Community Update

Welcome to the inaugural Community Platform Update. As part of our commitment to…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Community Spotlight of the Month

Kudos to Mohana Yadav!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,107 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,954 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans