Skip to main content
Question

Override method from abstract class


Forum|alt.badge.img+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

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+6
  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


Forum|alt.badge.img+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


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+6

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

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


Forum|alt.badge.img+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


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+6

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


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • June 21, 2023

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings