Unable to return DimensionAttributeValue record for 164

Hi, everyone!
I am writing a job to set financial dimension to a released product, while I try to run this code I’m getting an error,
My code is,

itemId = “1219100000”;
select forupdate inventTable
where inventTable.ItemId == itemId;

dimStorage = DimensionAttributeValueSetStorage::find(inventTable.DefaultDimension);
dimAttrOpDiv = DimensionAttribute::findByName(“MT01”);

dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrOpDiv, ‘164’, true, true);

inventTable.DefaultDimension = dimStorage.save();

can anyone help through this?.

Look at DimensionAttributeValue::findByDimensionAttributeAndValue method, it throws this error - if the value doesn’t exist and _createIfNecessary = true.

Do you want to create a value if it doesn’t exist?