Skip to main content
Solved

When publishing my graph extension (delegate), I get an error that the method does not exist in the graph


Joe Schmucker
Captain II
Forum|alt.badge.img+2

I know that in 15 minutes after posting this, I will find my stupid mistake. 

Until then, I get the following error when publishing my project:

Method System.Collections.Generic.List`1[PX.Objects.AP.APRegister] ReleaseInvoice(PX.Objects.GL.JournalEntry, PX.Objects.AP.APRegister ByRef, PX.Data.PXResult`4[PX.Objects.AP.APInvoice,PX.Objects.CM.CurrencyInfo,PX.Objects.CS.Terms,PX.Objects.AP.Vendor], Boolean, System.Collections.Generic.List`1[PX.Objects.IN.INRegister] ByRef, ReleaseInvoiceDelegate) in graph extension is marked as [PXOverride], but the original method with such name has not been found in PXGraph
This is the delegate I am using to override the ReleaseInvoice method.  It looks to me like it is within the APDocumentRelease Graph.  Any ideas why it is not publishing?  This code compiles with no reference errors at all.  The signature of my delegate looks spotless.  :-)

namespace PX.Objects.AP
{
    // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
    public class APDocumentRelease_Extension : PXGraphExtension<APDocumentRelease>
    {
        public delegate List<APRegister> ReleaseInvoiceDelegate(JournalEntry je, ref APRegister doc, PXResult<APInvoice, CurrencyInfo, Terms, Vendor> res, bool isPrebooking, out List<INRegister> inDocs);
        [PXOverride]
        public virtual List<APRegister> ReleaseInvoice(JournalEntry je, ref APRegister doc, PXResult<APInvoice, CurrencyInfo, Terms, Vendor> res, bool isPrebooking, out List<INRegister> inDocs, ReleaseInvoiceDelegate baseMethod)
        {
            //call the base method
            var result = baseMethod(je, ref doc, res, isPrebooking, out inDocs);

            //this is how I determined which method to override
            //APInvoiceEntry (graph)
            //        Release action
            //        signature public override IEnumerable Release(PXAdapter adapter)
            //
            //            PXLongOperation.StartOperation(this, delegate() { APDocumentRelease.ReleaseDoc(list, false); });
            //                
            //                This method is in the APDocumentRelease GRAPH        
            //                APDocumentRelease.ReleaseDoc
            //                signature public static void ReleaseDoc(List<APRegister> list, bool isMassProcess, bool isPrebooking, List<Batch> externalPostList) 
            //
            //                    ReleaseDocProc
            //                    signature public virtual List<APRegister> ReleaseDocProc(JournalEntry je, APRegister doc, bool isPrebooking, out List<INRegister> inDocs)
            //
            //                        THIS IS THE ONE I AM USING AS THE DELEGATE
            //                        ReleaseInvoice(je, ref doc, res, isPrebooking, out inDocs);
            //                        signature public virtual List<APRegister> ReleaseInvoice(JournalEntry je, ref APRegister doc, PXResult< APInvoice, CurrencyInfo, Terms, Vendor > res, bool isPrebooking, out List<INRegister> inDocs)
            //
            //                    this.Actions.PressSave();

            //THIS IS WHERE I WILL DO MY STUFF
            //for each AP document, check if there is a value in the UsrProjectID field (UDF) of the APRegister table
            //If there is, update the UsrProjectID (UDF) field in the Batch table 

            APRegisterExt itemAPExt = PXCache<APRegister>.GetExtension<APRegisterExt>(doc);

            Batch batch = SelectFrom<Batch>.
                Where<Batch.batchNbr.IsEqual<@P.AsString>>.
                View.Select(Base, doc.BatchNbr);

            BatchExt itemBatchExt = PXCache<Batch>.GetExtension<BatchExt>(batch);

            itemBatchExt.UsrProjectID = itemAPExt.UsrProjectID;

            return result;

        }
 

Best answer by Hughes Beausejour

Whether or not the ReleaseInvoice method exists in APDocumentRelease class depends on the Acumatica version you are using.

The ReleaseInvoice method is not present in APDocumentRelease in the version I’m using.
It is also not present in the Override list. In that context the error message is legitimate, the method doesn’t exists so it can’t be overridden:

I see some ReleaseDoc methods. Those are static and I believe you can’t override static methods. At least not like that, maybe with reflection.. which is a bad idea.

View original
Did this topic help you find an answer to your question?

2 replies

Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+2
  • Acumatica Developer Support Team
  • 91 replies
  • Answer
  • June 17, 2021

Whether or not the ReleaseInvoice method exists in APDocumentRelease class depends on the Acumatica version you are using.

The ReleaseInvoice method is not present in APDocumentRelease in the version I’m using.
It is also not present in the Override list. In that context the error message is legitimate, the method doesn’t exists so it can’t be overridden:

I see some ReleaseDoc methods. Those are static and I believe you can’t override static methods. At least not like that, maybe with reflection.. which is a bad idea.


Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+2
  • Acumatica Developer Support Team
  • 91 replies
  • June 18, 2021

To customize Release process, consider overriding the Action and using PXGraph.InstanceCreated method to intercept APDocumentRelease graph.

Actions names are less likely to change in future version when compared to methods name. Overriding the action is also less likely to create conflicts.

Example:

    public class SM_SOInvoiceEntry : FSPostingBase<SOInvoiceEntry>
    {

        [PXOverride]
        public virtual IEnumerable Release(PXAdapter adapter, Func<PXAdapter, IEnumerable> baseMethod)
        {
                PXGraph.InstanceCreated.AddHandler<ARReleaseProcess>((graph) =>
                {
                    graph.GetExtension<SM_ARReleaseProcess>().processEquipmentAndComponents = true;
                });


            return baseMethod(adapter);
        }
    }


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings