Get & Update Default Dimensions

Share on facebook
Share on twitter
Share on linkedin

The following example, will show how to set the value of a dimension within the default dimensions of a record (Ex: set AccountNum as Default Dimension on Vendor/Customer) in Dynamics 365 for Operations.

Make sure that your model also references Dimensions and SourceDocumentationsTypes models.
You need this because the classes & variables used , are for the moment present in both models. Ex: the ExtendedDataType for CustTable.DefaultDimension is LedgerDimensionValueSet which belongs to SourceDocumentationsTypes and DimensionValue belongs to Dimensions model.

In the example bellow i created a Pre-Handler for the update method on CustTable:

 // <summary>

    // </summary>
    // <param name="args"></param>
    [PreHandlerFor(tableStr(CustTable), tableMethodStr(CustTable, update))]
    public static void CustTable_Pre_update(XppPrePostArgs args)

        CustTable           custTable = args.getThis();
        DimensionAttributeValueSetStorage dimStorage;
        DimensionAttribute dimensionAttribute;
        DimensionValue currentDimensionValue;
        Counter i;


        // Build Dimensions Attribute Value Storage
        dimStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);

        //Get current value
        dimensionAttribute = DimensionAttribute::findByName(#dimensionName);
        currentDimensionValue = dimStorage.getDisplayValueByDimensionAttribute(dimensionAttribute.RecId);

        //Update Customer Financial Dimension if it does not exist
            dimStorage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, custTable.AccountNum,false,true));

            custTable.DefaultDimension =;

            //Return updated event arguments



Leave a comment

Fill in your details and we’ll be in touch​