RecId getDimension(str _ledgerAccount, str _businessUnit, str _costCentre, str _jurisdiction, str _subscriberType)
{
DimensionServiceProvider DimensionServiceProvider = new DimensionServiceProvider();
LedgerAccountContract LedgerAccountContract = new LedgerAccountContract();
DimensionAttributeValueContract ValueContract;
List ListValueContract = new List(Types::Class);
dimensionAttributeValueCombination dimensionAttributeValueCombination;
DimensionStorage dimStorage;
if (_businessUnit)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('BusinessUnit') ;
ValueContract.parmValue(_businessUnit);
ListValueContract.addEnd(ValueContract);
}
if (_costCentre)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('CostCentre') ;
ValueContract.parmValue(_costCentre);
ListValueContract.addEnd(ValueContract);
}
if (_jurisdiction)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('Jurisdiction') ;
ValueContract.parmValue(_jurisdiction);
}
if (_subscriberType)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('SubscriberType') ;
ValueContract.parmValue(_subscriberType);
ListValueContract.addEnd(ValueContract);
}
LedgerAccountContract.parmMainAccount(_ledgerAccount);
LedgerAccountContract.parmValues(ListValueContract);
dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);
dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
return dimensionAttributeValueCombination.RecId;
}
Wednesday, July 23, 2014
Setting LedgerDimension field on LedgerJournalTrans table in AX 2012 via X++ code
The following code can be used to update LedgerDimension field on the LedgerJournalTrans
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment