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

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...