Skip to main content

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

rArgumentNullException: 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

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


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. 

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

Error

Thanks,

EV


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. 


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