# Product Attributes Creation

**URL:** <https://www.dynamicsuser.net/t/product-attributes-creation/62848>\
**Category:** Developer Forum\
**Created:** [March 1, 2017, 11:00am UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848 "2017-03-01T11:00:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![SarathKumar](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SarathKumar](https://www.dynamicsuser.net/u/SarathKumar)\
**Post date:** [March 1, 2017, 11:00am UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848/1 "2017-03-01T11:00:07Z")

</div>

Hi All ,

Please tell me how to create product attributes(Shown in figure) for particular product using X++ code…

The attribute includes name and value…

Thanks in Advance…

 ![Attribute image.png](https://us1.discourse-cdn.com/flex023/uploads/dugusers/original/2X/5/57fe1face28931fa31ebdf9681813f2e2888d52a.png)

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [March 1, 2017, 1:26pm UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848/2 "2017-03-01T13:26:32Z")

</div>

You may have to insert data in \Data Dictionary\Tables\EcoResCategoryAttributeLookup  
Look at \Data Dictionary\Tables\EcoResCatalogControl\Methods\synchronizeCategoryAttributeLookup for the implementation.

---

<div class="post-metadata">

**Author:** ![SarathKumar](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SarathKumar](https://www.dynamicsuser.net/u/SarathKumar)\
**Post date:** [March 1, 2017, 1:36pm UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848/3 "2017-03-01T13:36:17Z")

</div>

Hi Kranthi ,  
Thanks for ur reply…  
I have created Attribute via findorcreate method in Ecoresattribute table.The problem is i have to add that attribute to product category…  
how to do this.?..

---

<div class="post-metadata">

**Author:** ![SarathKumar](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SarathKumar](https://www.dynamicsuser.net/u/SarathKumar)\
**Post date:** [March 1, 2017, 1:43pm UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848/4 "2017-03-01T13:43:12Z")

</div>

Hi Kranthi ,

Please tell me what i have to insert to that table…

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [March 1, 2017, 1:48pm UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848/5 "2017-03-01T13:48:25Z")

</div>

You have to insert the data in \Data Dictionary\Tables\EcoResCategoryAttribute  
and then \Data Dictionary\Tables\EcoResCategoryAttributeLookup (for this use same approach as \Data Dictionary\Tables\EcoResCatalogControl\Methods\synchronizeCategoryAttributeLookup)

---

<div class="post-metadata">

**Author:** ![SarathKumar](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SarathKumar](https://www.dynamicsuser.net/u/SarathKumar)\
**Post date:** [March 2, 2017, 9:45am UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848/6 "2017-03-02T09:45:04Z")

</div>

Hi Kranthi ,  
Thanks for ur reply.  
The attribute is created .can you tell me how to give value for that attribute…

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [March 2, 2017, 10:18am UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848/7 "2017-03-02T10:18:04Z")

</div>

You may have to insert data in,  
EcoResProductInstanceValue  
EcoResAttributeValue  
EcoResValue (it has sub types depending on the attribute data type)

Look into the below methods for reference,  
\Forms\EcoResAttributeValue\Methods\attributeChanged  
\Forms\EcoResAttributeValue\Methods\createValue

---

<div class="post-metadata">

**Author:** ![SarathKumar](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SarathKumar](https://www.dynamicsuser.net/u/SarathKumar)\
**Post date:** [March 2, 2017, 11:38am UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848/8 "2017-03-02T11:38:26Z")

</div>

Hi kranthi,  
Thanks for ur reply…  
I have a doubt in instance value for attribute…  
How can i map Attribute to instance value…  
As u said i have done the attribute creation…But the problem is In EcoresProductInstance table,the attribue is not getting updated…  
Tell me if i have done anything wrong…  
Thanks in advance…

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [March 2, 2017, 11:46am UTC](https://www.dynamicsuser.net/t/product-attributes-creation/62848/9 "2017-03-02T11:46:18Z")

</div>

Have you seen this? if you are unable to find the issue, please show us know your code.

public void createValue(EcoResValue newEcoResValue)  
{  
EcoResProductInstanceValue newEcoResProductInstanceValue;  
EcoResAttributeValue newEcoResAttributeValue;

ttsbegin;

// Create new EcoResValue record  
newEcoResValue.insert();

// Create EcoResProductInstanceValue record  
newEcoResProductInstanceValue = EcoResProductInstanceValue::findByProduct(callerMasterOrDistinctProduct.RecId);  
if (!newEcoResProductInstanceValue.RecId)  
{  
newEcoResProductInstanceValue.clear();  
newEcoResProductInstanceValue.Product = callerMasterOrDistinctProduct.RecId;  
newEcoResProductInstanceValue.insert();  
}

// Create EcoResAttributeValue record  
newEcoResAttributeValue = EcoResAttributeValue::findByInstanceAttribute(newEcoResProductInstanceValue.RecId, ecoResAttribute.RecId);  
if(!newEcoResAttributeValue)  
{  
newEcoResAttributeValue.clear();  
newEcoResAttributeValue.Value = newEcoResValue.RecId;  
newEcoResAttributeValue.InstanceValue = newEcoResProductInstanceValue.RecId;  
newEcoResAttributeValue.Attribute = ecoResAttribute.RecId;  
newEcoResAttributeValue.insert();  
}

ttscommit;  
}
