Create default dimension using x++

public DimensionDefault createDefaultDimension()
{
    DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
    DimensionDefault                    result;
    int                     i;
    DimensionAttribute      dimensionAttribute;
    DimensionAttributeValue dimensionAttributeValue;
    BIShopifyParameter _shopifyParameter;


    container               conAttr = ["Cars", "Department", "Company","Branch"];



    container               conValue ;

    str                     dimValue;
     select firstOnly _shopifyParameter;
  conValue  = [_shopifyParameter.CustomerCars, _shopifyParameter.CustomerDepartment, _shopifyParameter.CompanyId, _shopifyParameter.Branch];

    for (i = 1; i <= conLen(conAttr); i++)
    {
        dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
        if (dimensionAttribute.RecId == 0)
        {
            continue;
        }
        dimValue = conPeek(conValue,i);
        if (dimValue != "")
        {
            dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
            valueSetStorage.addItem(dimensionAttributeValue);
        }
    }

    result = valueSetStorage.save();
    //It reutrns the value of type DimensionDefault
    return result;
}

Leave Comment

Your email address will not be published. Required fields are marked *