Skip to main content
Answer

Base Method in a PXAction override delegate is null

  • October 31, 2024
  • 2 replies
  • 78 views

Joe Schmucker
Captain II
Forum|alt.badge.img+3

I’m overriding the Print Shipment Confirmation menu option on the Shipments screen

In my code, I want the option to use my override, or use the base method.

When I call the BaseMethod from my delegate, it is null.  I’m not sure what to do.

Here is the code for my override:

        [PXOverride]
public delegate IEnumerable PrintShipmentConfirmationDelegate(PXAdapter adapter);
[PXButton]
[PXUIField(DisplayName = "Shipment Confirmation")]
public IEnumerable PrintShipmentConfirmation(PXAdapter adapter, PrintShipmentConfirmationDelegate BaseMethod)
{
try
{
SOShipment shipment = Base.Document.Current;

string screenID = "SO302000";
string reportID = "SO642000";
string printerName;

ICSPrintHubActions iCSPrintHubActions = SelectFrom<ICSPrintHubActions>
.Where<ICSPrintHubActions.screenID.IsEqual<@P.AsString>
.And<ICSPrintHubActions.reportID.IsEqual<@P.AsString>>>.View.Select(Base, screenID, reportID);
if (iCSPrintHubActions == null)
{
throw new PXException(ICSMessages.PrintHubActionNotFound, screenID, reportID);
}

if (iCSPrintHubActions.Active == false)
{
if (BaseMethod != null)
{
return BaseMethod.Invoke(adapter);
}
else
{
return adapter.Get();
}
}

----the rest of the code is not needed to show here...

The idea is that if the iCSPrintHubAction is not active, fire the BaseMethod.Invoke(adapter);

At least that is what I think I need to do.

Note that if I get rid of the BaseMethod.Invoke stuff, the override does what I want.  I’m just trying to do the non-overridden action if the test record is not active.

Any ideas why my BaseMethod from the Delegate is null?

Best answer by Django

I think you want the PXOverride to be above the thing you’re overriding, not your delegate:


public delegate IEnumerable PrintShipmentConfirmationDelegate(PXAdapter adapter);
[PXButton]
[PXUIField(DisplayName = "Shipment Confirmation")]
[PXOverride]
public IEnumerable PrintShipmentConfirmation(PXAdapter adapter, PrintShipmentConfirmationDelegate BaseMethod)

 

2 replies

Forum|alt.badge.img+7
  • Captain II
  • Answer
  • October 31, 2024

I think you want the PXOverride to be above the thing you’re overriding, not your delegate:


public delegate IEnumerable PrintShipmentConfirmationDelegate(PXAdapter adapter);
[PXButton]
[PXUIField(DisplayName = "Shipment Confirmation")]
[PXOverride]
public IEnumerable PrintShipmentConfirmation(PXAdapter adapter, PrintShipmentConfirmationDelegate BaseMethod)

 


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • November 1, 2024

OMG...THIS IS THE SECOND TIME I HAVE DONE THIS!!  I even searched my previous posts and I didn’t see it.  I knew I recognized this error.

Thanks and sorry for the waste of your time!  

Love you guys...