![](https://uploads-us-west-2.insided.com/acumatica-en/attachment/2f150061-8b7a-44ad-b7eb-60a36cbd9fda.png)
To extend or override an existing public or protected virtual Action or method, create a delegate and use the PXOverride attribute on the new method. If the objective is to extend rather than override, call the original method through the delegate at the appropriate time.
In this case, either:
public delegate IEnumerable CreateInvoiceDelegate(PXAdapter adapter);
[PXOverride]
public virtual IEnumerable createInvoice(PXAdapter adapter, CreateInvoiceDelegate baseMethod)
{
// Execute original method
var result = baseMethod(adapter);
// your code (executed after the original)
//
return result;
}
or
public delegate IEnumerable CreateInvoiceDelegate(PXAdapter adapter);
[PXOverride]
public virtual IEnumerable createInvoice(PXAdapter adapter, CreateInvoiceDelegate baseMethod)
{
// your code (executed before the original)
//
// Execute original method
return baseMethod(adapter);
}
Hi
I extended the original CRCreateInvoice class but I get the following:
I’m not good with Español, but the second error is arising from the fact that CRCreateInvoice is not a graph, but rather a generic extension of a graph. For this reason, I believe you’ll need to write a graph extension for the specific graph you’re targeting. For Opportunities (one entity that uses CRCreateInvoice), it would look like this:
namespace Test
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class Test : PXGraphExtension<OpportunityMaint.CRCreateInvoiceExt, OpportunityMaint>
{
public delegate IEnumerable CreateInvoiceDelegate(PXAdapter adapter);
[PXOverride]
public virtual IEnumerable createInvoice(PXAdapter adapter, CreateInvoiceDelegate baseMethod)
{
// your code (executed before the original)
//
// Execute original method
return baseMethod(adapter);
}
}
}
Thank you,
I am passing the structure of the original method to the extension but I get this error that I can't solve.
The first error:
Error CS0246 The type or namespace name 'TDiscountExt' was not found (is a using directive or assembly reference missing?) customizationSipecom
of course
I can’t see the very end of the code, but it looks like you are just duplicating the original code. In that case, you’re going to have issues, because in the generic class, it uses generic types (ie: TDiscountExt, TGraph, TMaster). Your extension is using non-generic types.
In order to make this work for this particular instance, you’d have to replace the generic types with non-generic types:
var extension = graph.GetProcessingExtension<CRCreateInvoice<OpportunityMaint.Discount, OpportunityMaint, CROpportunity>>();
Thank you
I was very pleased with your help
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.