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:

public class YourExtension : PXGraphExtension<SomeBasicGraph>
{
[PXOverride]
public void MethodForOverriding(string viewName, IDictionary keys, IDictionary values, Func<string, IDictionary, IDictionary, int> methodDel)
{
   //some your code
   int res = methodDel(viewName, keys, values);
   //again some of your code. For example you can modify res.
   return res;
}
}

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

No Comments

Add a Comment