How to override base event in Acumatica

Hello everybody,

Imagine following scenario. You have some code in base class, which you need to change. How to do it. For this purpose you can use PXOverride attribute.

See the following code:

public class YourExtension : PXGraphExtension<SomeBasicGraph>
{
   [PXOverride]
   public void MethodForOverriding(string viewName, IEnumerable items)
   {
      // Method body
   }
}

In case which is presented MethodForOverriding of base class will be called. If you want to avoid it, you can add additional argument to the code,

and then manipulate how to call it or even omit calling of method from base logic. Look at the following code:

[Update, thanks to Taras Vynar]

public class YourExtension : PXGraphExtension<SomeBasicGraph>
{
  [PXOverride]
  public void MethodForOverriding(string viewName, IDictionary keys, IDictionary values, Action<string, IDictionary, IDictionary> methodDel)
  {
    //some your code
    methodDel(viewName, keys, values);
    //again some of your code. 
    return res;
  }
}

This is very similar to overriding events of DAC classes as mentioned here

Add comment

Loading