Sunday, March 26, 2017

Create Ledger Dimension from Existing ledger dimension with different mainaccount

//  Create Ledger Dimension from Existing ledger dimension with different mainaccount

//Another way to create or merging Ledger dimension

ledgerDimensionAccount buildDefaultAndLedgerDimension(LedgerDimensionAccount   _ledger,MainAccountNum _account = "")
    {
        DimensionAttributeValueSetStorage   dimensionAttributeValueSetStorage;
        DimensionAttributeValue             dimensionAttributeValue;
        DimensionDefault                    dimensionDefault;
        LedgerDimensionAccount              ledgerDimensionAccount;
        DimensionAttributeLevelValueAllView dimAttrValueallview;
        dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage();
        while select dimAttrValueallview where dimAttrValueallview.ValueCombinationRecId == _ledger
        {
            if(DimensionAttribute::find(dimAttrValueallview.DimensionAttribute).Name != "MainAccount")
            {
                    dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(
                                    DimensionAttribute::find(dimAttrValueallview.DimensionAttribute),
                                    dimAttrValueallview.DisplayValue, false, true);
                    dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
 
                dimensionDefault = dimensionAttributeValueSetStorage.save();
            }
        }
       
        ledgerDimensionAccount = DimensionDefaultingService::serviceCreateLedgerDimension(DimensionStorage::getDefaultAccountForMainAccountNum(_account),
                                                                                            dimensionDefault);
       
        return ledgerDimensionAccount;
    }
    ;

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...