Skip to main content
Question

How can I write a delegate for a method that has "params" argument?

  • February 17, 2024
  • 5 replies
  • 174 views

aaghaei
Captain II
Forum|alt.badge.img+10

Hello community,

I am wondering how can I write a delegate for a method that has "params" argument considering the params argument is needed to be the last parameter in the formal parameter list?
 

public delegate void RunLogActionBaseDelegate(string action, string logType, FSAppointmentDet apptDet, PXSelectBase<FSAppointmentLog> logSelect, params object[] logSelectArgs);
[PXOverride]
public virtual void RunLogActionBase(string action, string logType, FSAppointmentDet apptDet, PXSelectBase<FSAppointmentLog> logSelect, params object[] logSelectArgs, RunLogActionBaseDelegate baseMethod)
{
baseMethod?.Invoke(action, logType, apptDet, logSelect, logSelectArgs);
}

I tried to override the method Any help is appreciated.

5 replies

darylbowman
Captain II
Forum|alt.badge.img+15

Have you tried this?

public delegate void RunLogActionBaseDelegate(string action, string logType, FSAppointmentDet apptDet, PXSelectBase<FSAppointmentLog> logSelect, params object[] logSelectArgs);
[PXOverride]
public virtual void RunLogActionBase(string action, string logType, FSAppointmentDet apptDet, PXSelectBase<FSAppointmentLog> logSelect, RunLogActionBaseDelegate baseMethod, params object[] logSelectArgs)
{
//throw new PXException("Ran");
baseMethod(action, logType, apptDet, logSelect, logSelectArgs);
}

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • February 19, 2024

Hi @darylbowman Thank you for the suggestion. Yes I have tried to insert the Delegate as the first parameter as well as the last parameter befor “params” but in either case I get an error as follows. Sorry I should have mentioned this in my original post to prevent others from wasting time on it.

Method Void RunLogActionBase(System.String, System.String, PX.Objects.FS.FSAppointmentDet, PX.Data.PXSelectBase`1[PX.Objects.FS.FSAppointmentLog], RunLogActionBaseDelegate, System.Object[]) in graph extension is marked as [PXOverride], but its signature is not compatible with original method

 

Also in case someone else will look into this thread I have tried the below as well

[PXOverride]
public virtual void RunLogActionBase(string action, string logType, FSAppointmentDet apptDet, PXSelectBase<FSAppointmentLog> logSelect, params object[] logSelectArgs)
{
Base.RunLogActionBase(action, logType, apptDet, logSelect, logSelectArgs);
}

but I get the famous error of 

Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space.

 


darylbowman
Captain II
Forum|alt.badge.img+15

From what I’m finding on StackOverflow, this isn’t possible, although I’m not certain I understand all of it.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • March 29, 2024

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


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • March 30, 2024

Hi @Chris Hackett I don’t think it is doable