Just check this DimensionDefaultingControllerBase Class, addEditControls method.
if (dimLinkMarkFieldOptionalEventArgs.parmCancel())
{
valueStringControl.mandatory(true);//This is set to mandatory
}
If we have any requirement To set mandatory Just write code here.But this is not the best way.For best way . . .
Just follow the below steps:
1. Create Class in AOT node and set name as PurchEventHandler.
2.Right Click on Class and select New, Click on Pre- or-Post EventHandler.
3.Write below method on Class.
public static void purchValidateWrite(XppPrePostArgs _args)
{
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
DimensionAttributeValueSetItem dimAttrValueSetItem;
PurchLine purchLoc,purchLineLoc;
RefRecId defaultDimension;
VendGroup vendGroup;
boolean ret;
;
#define.CostCenter('CostCenter')
purchLoc = _args.getThis();
ret = _args.getReturnValue();
defaultDimension = purchLoc.DefaultDimension;
dimAttr = DimensionAttribute::findByName(#CostCenter);
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("CostCenter must be specified.");
}
// }
_args.setReturnValue(ret);
}
4.Select PurchLine in AOT and select ValidateWrite_server and Right click on that method.Select New Event Handler Subscription.
5.Give properties Name,CalledWhen::Post,ClassName,Method.
Create New purch Order and Enter line Details And save It throws the error.
Process Done.
For Sales Table Form
Same Like SalesTable From
1.Create New class Name it.
2.Right Click on Class and select New, Click on Pre- or-Post EventHandler.
3.Write below code in method.
public static void salesLineValidateWrite(XppPrePostArgs _args)
{
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
DimensionAttributeValueSetItem dimAttrValueSetItem;
SalesLine salesLoc,salesLineLoc;
RefRecId defaultDimension;
CustGroup custGroup;
boolean ret;
;
#define.CostCenter('CostCenter')
salesLoc = _args.getThis();
ret = _args.getReturnValue();
select DaxCustGroupMandatory from custGroup
join salesLineLoc
where salesLineLoc.CustGroup==custGroup.CustGroup &&
salesLineLoc.CustAccount == salesLoc.CustAccount;
if (custGroup.DaxCustGroupMandatory==NoYes::Yes)
{
defaultDimension = salesLoc.DefaultDimension;
dimAttr = DimensionAttribute::findByName(#CostCenter);
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("CostCenter must be specified.");
}
}
_args.setReturnValue(ret);
}
4. Select SalesLine in AOT and select ValidateWrite_server and Right click on that method.Select New Event Handler Subscription.
5.Give properties Name,CalledWhen::Post,ClassName,Method.
Keep Daxing !!
No comments:
Post a Comment