Sunday, October 23, 2016

How to get item's attribute value

We can get specific item's attribute using below code.

public static str dGetItemAttribute()
{
InventTable inventTableChk;
AttributeValueText getItemIdAttributeValue(ItemId   _itemId,
_attributeName)
{
EcoResProductAttributeValue ecoResProductAttributeValue;
AttributeValueText          attributeValueText;
InventTable                 InventTable;
EcoResAttribute             ecoResAttribute;
EcoResValue                 ecoResValue;
;
select Product from InventTable where InventTable.itemid == _itemId
    join RecId from ecoResProductAttributeValue
        where ecoResProductAttributeValue.Product == InventTable.Product
    join Name from ecoResAttribute
        where ecoResProductAttributeValue.Attribute == ecoResAttribute.RecId
            && ecoResAttribute.Name == _attributeName
    join ecoResValue
        where ecoResValue.RecId == ecoResProductAttributeValue.Value;

if (ecoResValue)
    attributeValueText = ecoResValue.value();
else
    attributeValueText = "Value? Product attribute";

return attributeValueText;
}
;
while select ItemId from InventTableChk
{
    // get value of attribute "2. Publish Price"
    info(strFmt('%1', getItemIdAttributeValue(inventTableChk.ItemId, '2. Publish Price')));
}
}

No comments:

Post a Comment