Question

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

  • 17 February 2024
  • 5 replies
  • 67 views

Userlevel 7
Badge +8

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

Badge +11

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);
}

 

Userlevel 7
Badge +8

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.

 

Badge +11

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

Userlevel 7
Badge

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

Userlevel 7
Badge +8

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

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved