Hi everybody,
please consider this situation: you create an extension class MyClass_Extension of a class Class, where you add a new method and you augment the functionality of an existing method of the class Class using chain of command to call the new method. Moreover you extend Class in MyClassSon, overriding the new method introduced with MyClass_Extension.
If you try to call the new method from an instance of MyClassSon, D365 executes the code of MyClass_Extension. Is there any way to override it in MyClassSon?
Here the minimal example to reproduce it:
class AClass
{
public void run()
{
info("AClass");
}
}
//extension class
[ExtensionOf(classStr(AClass))]
final class AClass_Extension
{
public void run()
{
next run();
this.myRun();
}
public void myRun()
{
info("AClass_Extension");
}
}
// class extension
class AClassExtension extends AClass
{
public void myRun()
{
info("AClassExtension");
}
}
class RunnableTest
{
static void main (Args _args)
{
AClassExtension a = new AClassExtension();
a.run();
// I obtain the output:
// - AClass
// - AClass_Extension
// where I would like to obtain
// - AClass
// - AClassExtension
}
}
My doubt is that since MyClass_Extension must be declared final, its methods cannot be overridden, but I can't find this information in
MS documentation. Can you please confirm this?
Thank you very much and regards,
Nicola