Quantcast
Channel: AX Developer Forum
Viewing all articles
Browse latest Browse all 9880

Ax 2012: Creation new values for standard dimensions

$
0
0

Dear All, I need to create values for standard dimension. I tried with following code

static void DEV_CreateDefaultDimension(Args _args)
{
    DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
    DimensionDefault                    result;      
    int                     i;
    DimensionAttribute      dimensionAttribute;
    DimensionAttributeValue dimensionAttributeValue;
   
    // Note that "Item" is not one of the default dimension,
    // but DimensionAttributeValueSetStorage will handle it gracefully
    container               conAttr = ["Department", "ExpensePurpose", "Item"];
    container               conValue = ["00000028", "Training", "1000"];   
    str                     dimValue;                
    for (i = 1; i <= conLen(conAttr); i++)
    {               
        dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));       
        if (dimensionAttribute.RecId == 0)
        {
            continue;
        }       
        dimValue = conPeek(conValue,i);       
        if (dimValue != "")
        {
            // The last parameter is "true". A dimensionAttributeValue record will be created if not found.
            dimensionAttributeValue =
                    dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);           
            // Add the dimensionAttibuteValue to the default dimension
            valueSetStorage.addItem(dimensionAttributeValue);
        }               
    }          
    result = valueSetStorage.save();   
}

After running this job I get error "Unable to return DimensionAttributeValue record for 0000028".

I need to insert value "0000028" for department dimension.

Please help to resolve this issue??


Viewing all articles
Browse latest Browse all 9880

Trending Articles