Solved

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

  • 17 June 2021
  • 2 replies
  • 593 views

Userlevel 6
Badge +3

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;

        }
 

icon

Best answer by Hughes Beausejour 17 June 2021, 23:40

View original

2 replies

Userlevel 5
Badge +2

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.

Userlevel 5
Badge +2

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


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