![]()
Hello Experts,
Here my requirement is to bring the value from product category from to Financial dimension ProductCategory. I found the following code and it works fine for standard FD like Department BusinessUnit etc but not for ProductCategory :
staticvoid replaceDefaultDimensionsCondenseproduct3(Args _args)
{
InventTable inventTable = InventTable::find("1001-000000007"); //Customer Record containing Financial Dimension
Struct struct = new Struct(); //Structure to hold the dimension values to replace
container defDimensionCon; //Container to prepare the required values and dimension attribute combination
DimensionDefault dimensionDefault; //Get the replaced dimension recid
DimensionAttributeSetItem dimAttrSetItem; //Table to get active dimensions for the legal entity
DimensionAttribute dimAttribute; //Table to get the Financial dimensions
// AgreementLine inventtable ;//= AgreementLine::fin("CHICK PEAS");
DimensionAttributeValueSetStorage dimStorage,dimstorageInvent;
int i; //For looping
// select inventtable where inventtable.ItemId == "CHICK PEAS";
dimstorageInvent = DimensionAttributeValueSetStorage::find(inventTable.DefaultDimension);
//Loop for required dimensions
whileselect Name, BackingEntityType from dimAttribute
where dimAttribute.BackingEntityType == tableNum(DimAttributeOMBusinessUnit) ||
dimAttribute.BackingEntityType == tableNum(DimAttributeOMDepartment) ||
dimAttribute.BackingEntityType == tableNum(DimAttributeHcmWorker )||
dimAttribute.BackingEntityType == tableNum(DimAttributeCustTable)
&&
dimAttribute.Type != DimensionAttributeType::DynamicAccount
join dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimAttribute.RecId &&
dimAttrSetItem.DimensionAttributeSet == DimensionCache::getDimensionAttributeSetForLedger()
{
//Add the Dimension name and display value to struct
if (dimAttribute.BackingEntityType == tableNum(DimAttributeOMBusinessUnit))
{
struct.add(dimAttribute.Name, "VT005");
}
}
//Prepare the container
defDimensionCon += struct.fields();
for (i = 1; i <= struct.fields(); i++)
{
defDimensionCon += struct.fieldName(i);
defDimensionCon += struct.valueIndex(i);
}
//if there are fields in struct
if (struct.fields())
{
//Get the DimensionAttributeValueSet table’s Record ID
dimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(defDimensionCon);
//Update to Invent Master
ttsBegin;
inventTable.selectForUpdate(true);
if (inventTable.DefaultDimension)
{
inventTable.DefaultDimension = DimensionDefaultingService::serviceMergeDefaultDimensions(dimensionDefault, inventTable.DefaultDimension);
}
else
{
inventTable.DefaultDimension = dimensionDefault;
}
inventTable.doUpdate();
ttsCommit;
}
}
If I run this job then BusinessUnit value is getting set but if I try for product category it doesn't work I believe AX does not have any View like we have in this case DimAttributeOMBusinessUnit.
Please suggest some solution or any other piece of code or any altenate solution, Here data source behind "ProductCategory" form is EcoResCategory (Field >> Name).
Thanks in advance.