Skip to main content

Notifications

Announcements

No record found.

MSdynD365FO : Edit method for dimension

Sukrut Parab Profile Picture Sukrut Parab 71,645 Moderator

I have seen multiple post on the community about edit method for dimensions .  I have recently created one for my use in one of the requirement . Below is x++ code  for it 

edit DimensionValue EditDepartmentInGrid(boolean _set, DimensionValue _value)
    {
        DimensionValue                      dimValue;
        Name                                dimName;		    
        RefRecId                            deptRecId;
        DimensionAttributeValueSetStorage   davsStorage;
        DimensionAttributeValue             dimAttrValue;
        Counter                             i;

        if(_set)
        {
            davsStorage = DimensionAttributeValueSetStorage::find(this.DefaultDimension);

            if(davsStorage)
            {
                deptRecId = OMOperatingUnit::findName(_value, OMOperatingUnitType::OMDepartment).RecId;
                dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndEntityInst(DimensionAttribute::caaFindByOriginalName(caaOriginalDimension::Department).recid, deptRecId, false, true);
                    
                if (dimAttrValue)
                {
                    davsStorage.addItemValues(dimAttrValue.DimensionAttribute, dimAttrValue.RecId, dimAttrValue.HashKey);
                    this.DefaultDimension = davsStorage.save();
                }
            }
        }

       dimValue = '';
       dimStorage = null;
    
           
        for (i = 1; i <= dimStorage.elements(); i++)
        {
            dimName = DimensionAttribute::find(davsStorage.getAttributeByIndex(i)).Name;
    
            if (dimName == ‘Department’)
            {
                dimValue = dimStorage.getDisplayValueByIndex(i);
                break;
            }
        }
   return dimValue;
        
}


Comments

*This post is locked for comments