Create Default dimension using x++

The following job will get a DimensionAttributeValueSet record ID base on the a set of dimension values.


static void CreateDefaultDimensions(Args _args)
PurchTable purchTable;
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 = [“Project”, “Vendor”]; // Dimensions
container conValue = [“1001”, “Ven-0046”]; //  respective Values
str dimValue;

purchTable = purchTable::find(‘000471’);

for (i = 1; i <= conLen(conAttr); i++)
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));

if (dimensionAttribute.RecId == 0)

dimValue = conPeek(conValue,i);

if (dimValue != “”)
// The last parameter is “true”. A dimensionAttributeValue record will be created if not found.
dimensionAttributeValue =

// Add the dimensionAttibuteValue to the default dimension

result =;
purchTable.DefaultDimension = result;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s