Search code examples
acumatica

Collecting Graph data during Process invoice and memos process button


I am currently upgrading code from Build 19.213.0029 to Build 21.201.0086.

I have code running during the release of an invoice.

namespace JVDnamespace 
{
    public class JVDSOInvoiceEntry_Extension : PXGraphExtension<SOInvoiceEntry>
    {
        public static bool IsActive() => true;

        #region Event Handlers
        public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
        [PXOverride]
        public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
        {

            if ( !(Base.Document.Current is null) && !(Base.Document.Current.CuryOrigDocAmt is null))
            {
                setCreditLimit(Base.Document.Current.CustomerID.Value, Base.Document.Current.CuryOrigDocAmt.Value);
            }

            return baseMethod(adapter); ;
        }

I use the Process Invoice and Memos(SO505000) to process/Release all my documents and then the code above would do a calculation for me.

The problem is with the new version of Acumatica(Build 21.201.0086) Base.Document.current is null and I can find a way to see what document is currently being processed. This is not the case if you release the document from the Invoice(SO303000) then the current data is populated.

Question: Is there a new way or another way to get the current CustomerID and CuryOrigDocAmt during processing(release) on Page 'Process Invoice and Memos(SO505000)'.


Solution

  • You can use adpater.Get<ARInvoice>() to get a list of the invoices that are being released and then execute whatever logic you need per invoice. This should work on both pages if you are releasing from the Entry page it will just be a list of that invoice only.

    public class SOInvoiceEntryExt : PXGraphExtension<SOInvoiceEntry>
    {
        public static bool IsActive() => true;
    
        public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
        [PXOverride]
        public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
        {
            foreach(ARInvoice inv in adapter.Get<ARInvoice>())
            {
                // Exceute logic here per invoice
            }
            return baseMethod(adapter); ;
        }
    }