@junmao01 Yes, we can remove the old formula and add new formula using Cache Attached event like below.
"PXMergeAttributes(Method = MergeMethod.Merge)]
PXRemoveBaseAttribute(typeof( PXUnboundFormulaAttribute))] // This code will remove the base formula
//Below you can add the new formula according to your requirement
PXUnboundFormula(typeof(IIf<Where<POLine.cancelled, Equal<True>>, decimal0, POLine.curyExtCost>), typeof(SumCalc<POOrder.curyLineTotal>))]
protected virtual void POOrder_FieldName_CacheAttached(PXCache sender)
{
}
@Naveen Boga Thanks for your reply. I tested PXRemoveBaseAttribute in the field. But the PXUnboundFormula is defined in the POTAX attribute. The PXRemoveBaseAttribute in the field doesn’t work. I end with inherit the POTAXAttribute, and clear the base attribute and define a new one.
public class POTaxCBIZAttribute : POTaxAttribute
{
public POTaxCBIZAttribute(Type ParentType, Type TaxType, Type TaxSumType)
: base(ParentType, TaxType, TaxSumType)
{
base._Attributes.Clear();
this._Attributes.Add(new PXUnboundFormulaAttribute(typeof(IIf<Where<POLine.cancelled, Equal<True>>, decimal0, POLine.curyExtCost>), typeof(SumCalc<POOrder.curyLineTotal>)));
}
}
Thanks.