Skip to main content

Overriding an Action but the Override Action Delegate is null

  • 3 July 2024
  • 3 replies
  • 36 views

I am trying to override an action on the Production Orders screen.  I am following the instructions that @Naveen Boga provided here:

However, when I get to the invoke method the “BaseMethod” is null and throws an error.

The override fires when you click the button, but the Delegate is null.

public delegate IEnumerable LinkSalesOrderDelegate(PXAdapter adapter);
public IEnumerable LinkSalesOrder(PXAdapter adapter, LinkSalesOrderDelegate BaseMethod)
{
AMProdItem curr = Base.ProdItemSelected.Current;
if (curr == null) return adapter.Get();

//if parent is filled, it is NOT the original, so don't unlink the prod order from the SO
if (curr.ParentOrdID != null)
{
curr.OrdNbr = null;
curr.OrdLineRef = null;
curr.OrdTypeRef = null;
curr.CustomerID = null;

AMProdItemExt ext = curr.GetExtension<AMProdItemExt>();
if (ext != null)
{
ext.UsrItemPrice = null;
ext.UsrOrderQty = null;
}

Base.ProdItemSelected.UpdateCurrent();
Base.Actions.PressSave();

return adapter.Get();
}
else
{
AMProdItemExt ext = curr.GetExtension<AMProdItemExt>();
if (ext != null)
{
ext.UsrItemPrice = null;
ext.UsrOrderQty = null;
}
Base.ProdItemSelected.UpdateCurrent();

return BaseMethod.Invoke(adapter);
}
}

Any ideas why?

The goal: if you unlink a SO from a Production Order and the current order is not the “Parent” order, I don’t want to remove the Parent Production order from the SOLine.

3 replies

Userlevel 7
Badge +3

I found the answer in a different solution provided by @Naveen Boga 

 

The only thing that was wrong was the order in which I put PXOverride!

Instead of:

        [PXOverride]
        public delegate IEnumerable LinkSalesOrderDelegate(PXAdapter adapter);
It should be:

        public delegate IEnumerable LinkSalesOrderDelegate(PXAdapter adapter);
        [PXOverride]

When entered the question, it did not show the link above.  It only showed it to me AFTER I clicked submit.


Is there a way to mark this as solved by Naveen?  I don’t want to take credit for Naveen’s solution! 

Userlevel 7
Badge

Thank you for sharing the solution @Naveen Boga was able to provide @Joe Schmucker! Unfortunately there isn’t a way to credit him in this post. I did convert this question to a conversation so there’s no need to mark an answer 😀

Userlevel 7
Badge +3

Thanks @Chris Hackett !  

 

Reply