PXAccumulator: Customization of an Existing Accumulator Attribute

Suppose that a field on an MYOB Acumatica form is updated with an accumulator attribute and you need to modify this field behavior, which is implemented in the accumulator attribute. For example, you may need to eliminate restrictions that are defined in an accumulator attribute. To customize an existing accumulator attribute, instead of overriding it, you do the following:

  1. Create a custom accumulator attribute that is derived from PXAccumulatorAttribute, and include all needed code. For details about implementation, see PXAccumulator: Implementation of a Custom PXAccumulator Attribute.
  2. In the Initialize() method of the graph extension, replace PXCache.Interceptor with a new instance of the custom attribute, as shown in the following code example.
    Note:
    The system will use the custom accumulator attribute only in the graph for which you override the Initialize() method.
    public class INDocumentRelease_Extension : PXGraphExtension<INDocumentRelease>
    {
        public override void Initialize()
        {
            base.Initialize();
            PXCache cacheBase = Base.Caches[typeof(AverageCostStatus)];
            cacheBase.Interceptor = new CustomCostStatusAccumulatorAttribute(
                typeof(AverageCostStatus.qtyOnHand), 
                typeof(AverageCostStatus.totalCost), 
                typeof(AverageCostStatus.inventoryID), 
                typeof(AverageCostStatus.costSubItemID), 
                typeof(AverageCostStatus.costSiteID), 
                typeof(AverageCostStatus.layerType), 
                typeof(AverageCostStatus.receiptNbr));
        }
    }