How to update default dimension in Dynamics AX 2012 Through X++



How to update default dimension in Dynamics AX 2012 Through X++

static void  updateDefaultDimension(Args _args)
{
 
    DimensionAttributeValueSetStorage   dimStorage;
    DimensionAttribute                             dimAttr;
    DimensionAttributeValue                    dimAttributeValue;
    DimensionDefault                                defaultDimension;
    SalesTable                                            salesTable  = SalesTable::find('1000210',true);
 
 
    ttsBegin;
    dimStorage            = DimensionAttributeValueSetStorage::find(salesTable.DefaultDimension);
    dimAttr                  = DimensionAttribute::findByName("Dimension name");
    dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, "1555" , true, true);
    dimStorage.addItem(dimAttributeValue);

    defaultDimension    = dimStorage.save();

    salesTable.DefaultDimension = defaultDimension;
    salesTable.update();
    ttsCommit;

}

Comments

Popular posts from this blog

How to loop through enum in dynamics ax 2012 using x++

How to read from csv file in Dynamics AX 2012 Through X++

How to Create Transfer Journal in Dynamics AX 2012 Through X++