Skip to content
Snippets Groups Projects
displayValueProcess.js 854 B
import("system.db");
import("system.result");
import("system.vars");
import("Attribute_lib");
import("Keyword_lib");

var attrType = AttributeUtil.getAttributeType(vars.get("$field.AB_ATTRIBUTE_ID"));
var value;
if (attrType == $AttributeTypes.COMBO)
    value = AttributeUtil.getSimpleAttributeName(vars.get("$field.VALUE"));

//TODO this is a workaround for keywords, when it's possible to use the consumer remove this else if
else if (attrType == $AttributeTypes.KEYWORD)
{
    var keywordContainer = db.cell(
        SqlCondition.begin()
            .andPrepareVars("AB_ATTRIBUTE.AB_ATTRIBUTEID", "$field.AB_ATTRIBUTE_ID")
            .buildSql("select KEYWORD_CONTAINER from AB_ATTRIBUTE")
    );
    value = KeywordUtils.getViewValue(keywordContainer, vars.get("$field.VALUE"));
}

else
    value = vars.get("$field.VALUE");

result.string(value);