Hi,
Each of our released products have a financial dimension (Business Unit). We have multiple business units under one entity. Released products cannot be shared across business dimensions. In the below code snipped I am looping through released products then looking up the product's financial dimension. If found, and the product dimensions is the same as the customer financial dimension, break the while loop. If there a better way to do this query?
var cust = CustTable::find(account);
var custBusinessDim = WSTG_Helpers::GetDimensionDisplayValue(cust.DefaultDimension, "BusinessUnit");
InventTable inventTable;
MCRInventTable mInventTable;
while select inventTable
where inventTable.WSTG_MFGPartNo == productId
join mInventTable where mInventTable.InventTable == inventTable.RecId
{
// lookup the dimension value
var productDim = WSTG_Helpers::GetDimensionDisplayValue(inventTable.DefaultDimension,"BusinessUnit");
if(productDim == custBusinessDim)
{
break;
}
}
public static str GetDimensionDisplayValue(RecId defaultDimension, Name dimName)
{
DimensionAttributeValueSetStorage dimStorage;
dimStorage = DimensionAttributeValueSetStorage::find(defaultDimension);
return dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName(dimName).RecId);
}