miércoles, 26 de septiembre de 2018

Uso de Dimensiones en D365

Como mucho ya han notado, el tema de las dimensiones en D365 ha cambiado a diferencia de otras versiones como en ax2012. les dejó un pequeño método de ejemplo para la creacion de dimenciones por código que talvez los puede orientar:

public DimensionDynamicAccount generateLedgerDimension(MainAccountNum _mainAccount)
{
    int hierarchyCount;
    LedgerRecId            ledgerRecId;
    MainAccount mainAccount;
    RefRecId recordvalue;                
    DimensionSetSegmentName DimensionSet;
    DimensionStorage         dimStorage;
    LedgerAccountContract LedgerAccountContract = new LedgerAccountContract();
    dimensionAttributeValueCombination dimensionAttributeValueCombination;

    mainAccount = MainAccount::findByMainAccountId(_mainAccount);
    if(mainAccount)
    {
        recordvalue = DimensionHierarchy::getAccountStructure(mainAccount.RecId,Ledger::current());
        hierarchyCount = DimensionHierarchy::getLevelCount(recordvalue);
        DimensionSet = DimensionHierarchyLevel::getDimensionHierarchyLevelNames(recordvalue);        
            
        LedgerAccountContract.parmMainAccount(mainAccount.MainAccountId);

        dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);
        dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
        ledgerRecId = dimensionAttributeValueCombination.RecId;
    }
    return ledgerRecId;
}