[PreHandlerFor(tableStr(CustTable), tableMethodStr(CustTable, validateWrite))]
public static void CustTable_Pre_validateWrite(XppPrePostArgs args)
{
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
DimensionAttributeValueSetItem dimAttrValueSetItem;
CustTable custTable;
RefRecId defaultDimension;
boolean ret;
custTable = args.getThis();
ret = args.getReturnValue();
defaultDimension = custTable.DefaultDimension;
dimAttr = DimensionAttribute::findByName('Department');
select firstonly RecId, DisplayValue from dimAttrValueSetItem
where dimAttrValueSetItem.DimensionAttributeValueSet == defaultDimension
join dimAttrValue
where dimAttrValue.RecId == dimAttrValueSetItem.DimensionAttributeValue &&
dimAttrValue.DimensionAttribute == dimAttr.RecId &&
dimAttrValue.IsDeleted == false;
if (!dimAttrValueSetItem.DisplayValue)
{
ret = checkFailed("Department must be specified.");
}
args.setReturnValue(ret);
}