Skip to main content
Solved

Problem overriding extension method

  • 14 December 2023
  • 2 replies
  • 115 views

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);
ePXOverride]
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 tPXProtectedAccess]: PX.Objects.IN.GraphExtensions.LineSplittingExtension`4gPX.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?

2 replies

Badge +12

Try

public class POReceiptLineSplittingExtension_Extension : PXGraphExtension<POReceiptLineSplittingExtension, POReceiptEntry>

 

Userlevel 4
Badge +1

Thanks Daryl, worked first time. 

Reply