I want customer dimension mandatory when creating a new customer
Form> CustTable > Method
public boolean checkcustomer(RecId _ledgerDimID)
{
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
DimensionAttributeValueSetItem dimAttrValueSetItem;
RefRecId defaultDimension;
boolean ret;
;
defaultDimension = _ledgerDimID;
dimAttr = DimensionAttribute::findByName('Customer');
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("Customer dimension must be specified.");
}
else
{
ret = true;
}
return ret;
}
Form> CustTable > Method
public boolean checkcustomer(RecId _ledgerDimID)
{
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
DimensionAttributeValueSetItem dimAttrValueSetItem;
RefRecId defaultDimension;
boolean ret;
;
defaultDimension = _ledgerDimID;
dimAttr = DimensionAttribute::findByName('Customer');
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("Customer dimension must be specified.");
}
else
{
ret = true;
}
return ret;
}
go to form level custtable datasource validateWrite method
if(element.checkcustomer(CustTable.DefaultDimension) )
{
ret = true;
}
else
{
ret = false;
}
No comments:
Post a Comment