How to Update default dimension with "Fixed value" on a main account in ax 2012
static void tbs_UpdateMainAccountDefaultDimensions(Args _args)
{
MainAccountRecId mainAccountRecid = 5637172326;
DataAreaId dataAreaId = "CompanyId";
CompanyInfo companyInfo = CompanyInfo::findDataArea(CompanyId);
MainAccountLegalEntity mainAccountLegalEntity = MainAccountLegalEntity::findByMainAccountLegalEntity(mainAccountRecId,companyInfo.RecId,true);
DimensionValue costCenter = "0001";
DimensionValue customer = "10001";
str dimensionFixed = "Fixed";
str dimensionNotFixed = "NotFixed";
container con;
container con_Fixed;
int cnt = 0;
con = [0];
con_Fixed = ["DimensionFixed",1];
if (costCenter)
{
con += ["CostCenter", costCenter];
con_Fixed += ["CostCenter", dimensionNotFixed];
cnt++;
}
if (customer)
{
con += ["Customer", customer];
con_Fixed += ["Customer", dimensionFixed];
cnt++;
}
con = conPoke(con, 1, cnt);
con_Fixed = conPoke(con_Fixed, 2, cnt);
ttsBegin;
mainAccountLegalEntity.DefaultDimension = AxdDimensionUtil::getDimensionAttributeValueSetId(con);
mainAccountLegalEntity.FixedDimensions = AxdDimensionUtil::getDimensionAttributeSetId(con_Fixed);
mainAccountLegalEntity.update();
ttsCommit;
info("Done");
}
Comments
Post a Comment