Question

Override method from abstract class

  • 18 May 2023
  • 6 replies
  • 160 views

Userlevel 4
Badge +1

Hello, 

I would like to override the method called ‘IssueAvailable’ in class ‘SOOrderLineSplittingAllocatedExtension’.

The class is abstract so I’m not sure how to perform the override or even if this is possible.

namespace PX.Objects.SO.GraphExtensions.SOOrderEntryExt
{
[PXProtectedAccess(typeof(SOOrderLineSplittingExtension))]
public abstract class SOOrderLineSplittingAllocatedExtension : PXGraphExtension<SOOrderLineSplittingExtension, SOOrderEntry>
{
protected virtual void IssueAvailable(SOLine line, decimal? baseQty, bool isUncomplete)
{
//acumatica code
}
}
}

The code for the original class and method is show above (I’ve removed the from the IssueAvailable method). 
The method is protected virtual so I believe i should be able to override this, but the class is abstract and uses [PXProtectedAccess]. I’ve not sure how to handle these. 

namespace PX.Objects.SO.GraphExtensions.SOOrderEntryExt
{
public abstract class SOOrderLineSplittingExtension_Extension : PXGraphExtension<SOOrderLineSplittingAllocatedExtension, SOOrderLineSplittingExtension, SOOrderEntry>
{
[PXOverride]
protected virtual void IssueAvailable(SOLine line, decimal? baseQty, bool isUncomplete)
{
//my code
}
}
}

The code above is my attempt to override the IssueAvailable method. This compiles fine but when I add breakpoint to the original method and my override method I can see that the original method is called and mine if ignored. 
I’ve tried various ways to do this but I’m not having any success.

Does anyone know how to do this?

Thanks

Steve


6 replies

Userlevel 7
Badge +5
  1. You IssueAvailable method that you put PXOverride on must be public
  2. Your class should not be abstract

It should work after these two changes

Userlevel 4
Badge +1

Thanks for your reply @Dmitrii Naumov 

namespace PX.Objects.SO.GraphExtensions.SOOrderEntryExt
{
public class SOOrderLineSplittingExtension_Extension : PXGraphExtension<SOOrderLineSplittingAllocatedExtension, SOOrderLineSplittingExtension, SOOrderEntry>
{
[PXOverride]
public virtual void IssueAvailable(SOLine line, decimal? baseQty, bool isUncomplete)
{
//my code
}
}
}

My code has been updated, Abstract removed from the class and the method is now Public. It compiles fine but the website now returns an error. Everyone’s favorite error -’Object reference not set to an instance of an object’. Screen shot below.

Any more ideas?
I was wondering if the PXGraphExtension has been defined incorrectly?
PXGraphExtension<SOOrderLineSplittingAllocatedExtension, SOOrderLineSplittingExtension, SOOrderEntry>

Thank you
Steve

Userlevel 7
Badge +5

@stephenward03 Hm, I’ve not seen this before. 

Can you try making your graph abstract and putting the [PXProtectedAccess(typeof(SOOrderLineSplittingExtension))] on top?

Userlevel 4
Badge +1

Thanks again @Dmitrii Naumov 

The code now look like this, with PMProtectedAccess and an Abstract class.

namespace PX.Objects.SO.GraphExtensions.SOOrderEntryExt
{
[PXProtectedAccess(typeof(SOOrderLineSplittingExtension))]
public abstract class SOOrderLineSplittingExtension_Extension : PXGraphExtension<SOOrderLineSplittingAllocatedExtension, SOOrderLineSplittingExtension, SOOrderEntry>
{
[PXOverride]
public virtual void IssueAvailable(SOLine line, decimal? baseQty, bool isUncomplete)
{
//my code
}
}
}

Unfortunately the error still occurs. 
I also tried with Abstract but without PXProtectedAccess, in this case the website was accessable but the breakpoint on my override code wasn’t hit. 

Is there anything else to try?

Thanks
Steve

Userlevel 7
Badge +5

Seems like a bug then. Please create a support case.

Userlevel 7
Badge

Hi @stephenward03 were you able to find a solution? Thank you!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved