Friday, June 30, 2017

X++ code to Set Default dimension based on Dimension attribute and finanacial dimension Display Value in AX 2012


X++ code to Set Default dimension based on Dimension attribute and finanacial dimension Display Value in AX 2012 
Note:

1)Here DimensionDefault is financial dimension combination( i.e recid),
2)Name is Like Dimension attribute name(ex Department).
3)_dimvalue is Displayvalue


public static DimensionDefault setDefaultDimension(DimensionDefault defaultDimension, Name _dimensionAttributeName, str  _dimValue)

{

    DimensionAttributeValue             dimAttrValue;

    DimensionAttribute                  dimAttr;

    DimensionAttributeValueSetStorage   dimAttrValueSetStorage;



    dimAttrValueSetStorage = DimensionAttributeValueSetStorage::find(defaultDimension);



    dimAttr         = DimensionAttribute::findByName(_dimensionAttributeName);

    dimAttrValue    = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, _dimValue, false, true);

    if(dimAttrValue)

    {

        dimAttrValueSetStorage.addItem(dimAttrValue);

        return dimAttrValueSetStorage.save();

    }

    return defaultDimension;

}


Keep Daxing :)

No comments:

Post a Comment

Export a copy of the standard user acceptance testing (UAT) database

 Reference link: Export a copy of the standard user acceptance testing (UAT) database - Finance & Operations | Dynamics 365 | Microsoft ...