I´m developing an integration solution in D365 but I have problem with the ledger dimensions. It works fine to create the records in LedgerJournalTrans and the field ledgerDimension gets a value but if there is a a fixed value set on one of the main account it is never set. I have tried to explain my code below. The dimension values are added to a container and past on to LedgerDimensionDefaultingEngine together with Main account and Dimension Hierarchy. Sometimes dimension2 is not set from the file, then it should be set from a Fixed value instead but that is not working.
// runable Job
public static createDimensionJob(Args _args)
{
container con;
str 10 dimension1 = "first";
str 10 dimension2 = "second";
str 10 dimension3 = "third";
DimensionDefault defaultDimension;
recId mainAccountRecId;
recId dimHierarchyId;
LedgerDimensionAccount ledgerDimensionAccount;
LedgerJournalAC ledgerAccount = "1234";
con = conIns(con, 1, dimension1);
con = conIns(con, 2, dimension2);
con = conIns(con, 3, dimension3);
mainAccountRecId = MainAccount::findByMainAccountId(ledgerAccount).RecId;
defaultDimension = MyClass::createDefaultDimension(con);
dimHierarchyId = MyClass::getDimensionHierarchyId(ledgerAccount, defaultDimension);
ledgerJournalTrans.LedgerDimension = LedgerDimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(mainAccountRecId, dimHierarchyId, defaultDimension);
}
//MyClass
public static recId createDefaultDimension(container _conDimAttrValues)
{
DimensionFinancialTag dimFinancialTag;
FinancialTagCategory tagCategory;
DimensionAttributeDirCategory dimAttrDirCategory;
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
DimensionAttributeValueSetStorage dimAttrValueSetStorage;
int i;
str 10 strDimAttrValue;
// Create storage
dimAttrValueSetStorage = new DimensionAttributeValueSetStorage();
for (i = 1; i<=conLen(_conDimAttrValues); i++)
{
strDimAttrValue = conPeek(_conDimAttrValues,i);
if (strDimAttrValue)
{
// Find FinancialTag
select firstonly RecId
from dimFinancialTag
where dimFinancialTag.Value == strDimAttrValue
join RecId from tagCategory
where tagCategory.RecId == dimFinancialTag.FinancialTagCategory
join RecId from dimAttrDirCategory
where dimAttrDirCategory.DirCategory == tagCategory.RecId
join dimAttr
where dimAttr.RecId == dimAttrDirCategory.DimensionAttribute;
// Add to storage
if (dimFinancialTag.RecId)
{
dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, strDimAttrValue);
if (dimAttrValue.RecId)
{
dimAttrValueSetStorage.addItem(dimAttrValue);
}
}
}
}
*This post is locked for comments