Skip to main content
Answer

Problem overriding extension method

  • December 14, 2023
  • 2 replies
  • 274 views

Forum|alt.badge.img+1

Hello, I want to run some code when the ‘Line Details’ button is clicked on Purchase Receipts. Overriding the appropriate method seems like the way to go but I’m struggling to get the code to work. 

This is a screen shot with the button hightlighted

The button calls a method called ShowSplits, this displays a SmartPanel. I want to do something when the SmartPanel closes. Unfortunately this method is in an extension (POReceiptLineSplittingExtension) so I’ve tried to define the extensions in the class definition for my extension. My code looks like this

public class POReceiptLineSplittingExtension_Extension : PXGraphExtension<POReceiptLineSplittingExtension, LineSplittingExtension<POReceiptEntry, POReceipt, POReceiptLine, POReceiptLineSplit>, POReceiptEntry>
{
public delegate IEnumerable ShowSplitsDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable ShowSplits(PXAdapter adapter, ShowSplitsDelegate baseMethod)
{
var ret = baseMethod(adapter);
//Do Something
return ret;
}
}

This compiles but when I open the Purchase Receipts screen, the page crashes, I get the following message.

Graph extension PX.Objects.PO.GraphExtensions.POReceiptEntryExt.POReceiptLineSplittingExtension_Extension cannot refer to the following abstract graph extensions that are not marked as [PXProtectedAccess]: PX.Objects.IN.GraphExtensions.LineSplittingExtension`4[PX.Objects.PO.POReceiptEntry,PX.Objects.PO.POReceipt,PX.Objects.PO.POReceiptLine,PX.Objects.PO.POReceiptLineSplit].

 

I think this might be appearing because class LineSplittingExtension is defined as abstract. Can anyone advise how I can get access to the ShowSplits method in POReceiptLineSplittingExtension?

Best answer by darylbowman

Try

public class POReceiptLineSplittingExtension_Extension : PXGraphExtension<POReceiptLineSplittingExtension, POReceiptEntry>

 

2 replies

darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • December 14, 2023

Try

public class POReceiptLineSplittingExtension_Extension : PXGraphExtension<POReceiptLineSplittingExtension, POReceiptEntry>

 


Forum|alt.badge.img+1
  • Author
  • Varsity III
  • December 14, 2023

Thanks Daryl, worked first time.