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;

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

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

dimStorage.addItem(dimAttributeValue);
inventTable.DefaultDimension = dimStorage.save();
inventTable.doUpdate();
}

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?