Wednesday, 16 November 2016

Update Ledger dimension through code in AX 2012 R3 (Account Structure) X++

Public void updateLedgerDimension(str 30 finMainaccount,str finArea,str fnCostCenter,str finFamily,str finBussiness,str finProject,str finSeason,str finCompany)
{
    List ListValueContract = new List(Types::Class);
    DimensionServiceProvider DimensionServiceProvider = new DimensionServiceProvider();
    LedgerAccountContract LedgerAccountContract = new LedgerAccountContract();
    updateValue = false;
    if(finArea)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Area') ;
        ValueContract.parmValue(finArea);
        ListValueContract.addEnd(ValueContract);
    }

    if(fnCostCenter)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('CostCenter') ;
        ValueContract.parmValue(fnCostCenter);
        ListValueContract.addEnd(ValueContract);
    }

    if(finFamily)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Family') ;
        ValueContract.parmValue(finFamily);
        ListValueContract.addEnd(ValueContract);
    }

    if(finBussiness)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Business') ;
        ValueContract.parmValue(finBussiness);
        ListValueContract.addEnd(ValueContract);
    }

    if(finProject)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Project') ;
        ValueContract.parmValue(finProject);
        ListValueContract.addEnd(ValueContract);
    }


    if(finSeason)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Season') ;
        ValueContract.parmValue(finSeason);
        ListValueContract.addEnd(ValueContract);
    }

    /*
    if(finCompany == "RND")
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Company') ;
        ValueContract.parmValue('');
        ListValueContract.addEnd(ValueContract);
    }
    */
        LedgerAccountContract.parmMainAccount(finMainaccount);
        LedgerAccountContract.parmValues(ListValueContract);


        dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);
        dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
        updateValue = true;
 }


For  finMainaccount,str finArea,str fnCostCenter,str finFamily,str finBussiness,str finProject,str finSeason,str finCompany this value please follow below link.

http://daxinfo.blogspot.in/2016/11/get-dimension-value-from-ledger.html

1 comment:

  1. Great blog. Thanks for share this post. It may helpful for all newbie bloggers, i really appreciate.Microsoft Dynamics AX consultants

    ReplyDelete