Solved

How to override an action in a graph extension?

  • 2 September 2022
  • 5 replies
  • 1015 views

Userlevel 2
Badge

Hi,

How I can override the CorrectInvoice action from the Correction graph extension?

I’m using this code, but the page give me an error.

public class Test : Correction
{
public static bool IsActive()
{
return true;
}

public override void Initialize()
{
base.Initialize();
}

public override IEnumerable CorrectInvoice(PXAdapter adapter)
{
return base.CorrectInvoice(adapter);
}



}

Error

[ArgumentNullException: Value cannot be null.Parameter name: key]   System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) +52   System.Collections.Generic.Dictionary`2.FindEntry(TKey key) +14244583   System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value) +21   PX.Web.UI.WebApi.Services.QPToolBarDataProvider.GetActionsSource(PXGraph graph, Boolean isPopupOn, Boolean popupInline, IScreenCommandsCustomInfo screenCommandsCustomInfo) +1495   PX.Web.UI.PXBaseDataSource.GetActionsSource() +305   PX.Web.UI.PXToolBar.IsToolbarEmpty() +53   PX.Web.UI.PXToolBar.Render(HtmlTextWriter writer) +195   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +132   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +271   PX.Web.UI.PXBaseDataSource.webControlRender(HtmlTextWriter writer) +141   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +132   PX.Web.UI.PXBaseDataSource.RenderControl(HtmlTextWriter writer) +50   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +271   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +132   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +271   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +47   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +132   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +271   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +208   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +47   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +132   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +69   ASP.masterpages_formdetail_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) +200   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +117   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +132   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +271   System.Web.UI.Page.Render(HtmlTextWriter writer) +39   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +132   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +9480

 

Thanks,

EV

icon

Best answer by Naveen Boga 3 September 2022, 05:52

View original

5 replies

Userlevel 6
Badge +4

Hi @edsonvelez64 

Can you look at these examples? 

How To Override Action Create At ... and  Stackoverflow

Graphs in Acumatica are handled differently from a normal OOP programing perspective.

Edited:

Graph Extensions in Acumatica

Userlevel 2
Badge

Hi @edsonvelez64 

Can you look at these examples? 

How To Override Action Create At ... and  Stackoverflow

Graphs in Acumatica are handled differently from a normal OOP programing perspective.

 

Hi,

I try with this code but is not working. 

[PXOverride]
public IEnumerable CorrectInvoice(PXAdapter adapter, Func<PXAdapter,IEnumerable> baseMethod)
{
return baseMethod(adapter);
}

Error

Thanks,

EV

Userlevel 6
Badge +4

Hi @edsonvelez64 

Can you try the following code?

namespace PX.Objects.SO.GraphExtensions.SOInvoiceEntryExt
{
public class Test : PXGraphExtension<Correction, SOInvoiceEntry>
{
public static bool IsActive()
{
return true;
}

[PXOverride]
public IEnumerable CorrectInvoice(PXAdapter adapter)
{
return Base1.CorrectInvoice(adapter);
}
}
}

Correction is already a graph extension. 

Userlevel 7
Badge +17

Hi, @edsonvelez64  Try like below and hope this helps!

Provided sample code for Base graph and extended graph for easy understanding.

namespace PX.Objects.SO
{
public class Correction : PXGraph<Correction>
{
public PXAction<SOOrder> CorrectInvoice;
[PXUIField(DisplayName = "Correct Invoice", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true)]
[PXButton()]
public virtual IEnumerable correctInvoice(PXAdapter adapter)
{
//Logic Here
return adapter.Get();
}
}
public class CorrectionExt : PXGraphExtension<Correction>
{
public static bool IsActive() => true;
[PXOverride]
public delegate IEnumerable CorrectInvoiceDelegate(PXAdapter adapter);
[PXButton]
[PXUIField]
public IEnumerable CorrectInvoice(PXAdapter adapter, CorrectInvoiceDelegate BaseMethod)
{
//Logic Here
return BaseMethod.Invoke(adapter);
}
}
}

 

I just posted this and wondered if anyone could take a look - it appeared this post was related. Tks

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