Skip to main content

The Purchase Order “Line Total” field is the summary of lines curyExtCost filed which is defined in the POTaxAttribute: PXUnboundFormulaAttribute(typeof(POLine.curyExtCost), typeof(SumCalc<POOrder.curyLineTotal>)).

I want to add a condition to the formula to exclude the Cancelled line: PXUnboundFormula(typeof(IIf<Where<POLine.cancelled, Equal<True>>, decimal0, POLine.curyExtCost>), typeof(SumCalc<POOrder.curyLineTotal>)).

How can I replace the original PXUnboundFormula with the new one, or can I Remove the old formula and add new formula?

 

Thanks,

@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.


Reply