Solved

Call checks and Payments item via Event

  • 20 January 2022
  • 5 replies
  • 54 views

Userlevel 4
Badge +2

Hi,

Previously I developed application that generates file when some Payment is Saved

It was done by calling this event 

 Now I need to do the same for Checks

I tried to create similar event , but I do not know how to define  such event

 

One important moment 

 that the event must be called only once, due to it generates file.It was advised to use that part of code  e.Cache.VerifyFieldAndRaiseException<ARPayment.refNbr>(e.Row);

And it perfectly worked the event was called only by once. How to do same for Cheks and Payments as what was done for Payments and Applications entity ?

icon

Best answer by jinin 21 January 2022, 06:34

View original

5 replies

Userlevel 7
Badge +11

Hi @Ivan 

We can use persist delegate override action and add the condition .only run the code when inserting the record.

Sample code:

 public class APPaymentEntry_Extension : PXGraphExtension<APPaymentEntry>
    {
        public static bool IsActive() { return true; }
       
        public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(Action del)
        {
            if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
            {

                foreach (var paymentrecord in Base.Document.Select())
                {
                    // Write your logic               

                }
            }
            del();
        }
    }

Userlevel 4
Badge +2

Hi @Ivan 

We can use persist delegate override action and add the condition .only run the code when inserting the record.

Sample code:

 public class APPaymentEntry_Extension : PXGraphExtension<APPaymentEntry>
    {
        public static bool IsActive() { return true; }
       
        public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(Action del)
        {
            if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
            {

                foreach (var paymentrecord in Base.Document.Select())
                {
                    // Write your logic               

                }
            }
            del();
        }
    }

Hi

I tried your sample of code and added check if payment method is “ARTSYL”, the csv will be generated

Unfortunately it did not worked. I checked PaymentMethodID name, it looks correct

Can you suggest what can be wrong ?

Userlevel 7
Badge +11

Hi @Ivan 

We can use persist delegate override action and add the condition .only run the code when inserting the record.

Sample code:

 public class APPaymentEntry_Extension : PXGraphExtension<APPaymentEntry>
    {
        public static bool IsActive() { return true; }
       
        public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(Action del)
        {
            if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
            {

                foreach (var paymentrecord in Base.Document.Select())
                {
                    // Write your logic               

                }
            }
            del();
        }
    }

Hi

I tried your sample of code and added check if payment method is “ARTSYL”, the csv will be generated

Unfortunately it did not worked. I checked PaymentMethodID name, it looks correct

Can you suggest what can be wrong ?




Hi @Ivan 

Did you debug and check the code trigger or not. Can you please check once.? As per your sample, you need to check only the paymentMethod.  I did a small modification to the code. Please try once.
 

 public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(Action del)
        {
            if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
            {

               if (Base.Document.Current.PaymentMethodID=="PaymentMethodName")
                {

                    //Add your logic
                }
            }
            del();
        }

 

Userlevel 4
Badge +2

Hi @Ivan 

We can use persist delegate override action and add the condition .only run the code when inserting the record.

Sample code:

 public class APPaymentEntry_Extension : PXGraphExtension<APPaymentEntry>
    {
        public static bool IsActive() { return true; }
       
        public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(Action del)
        {
            if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
            {

                foreach (var paymentrecord in Base.Document.Select())
                {
                    // Write your logic               

                }
            }
            del();
        }
    }

Hi

I tried your sample of code and added check if payment method is “ARTSYL”, the csv will be generated

Unfortunately it did not worked. I checked PaymentMethodID name, it looks correct

Can you suggest what can be wrong ?




Hi @Ivan 

Did you debug and check the code trigger or not. Can you please check once.? As per your sample, you need to check only the paymentMethod.  I did a small modification to the code. Please try once.
 

 public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(Action del)
        {
            if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
            {

               if (Base.Document.Current.PaymentMethodID=="PaymentMethodName")
                {

                    //Add your logic
                }
            }
            del();
        }

 

It worked. Thanks for assistance 

Userlevel 7
Badge +11

Great @Ivan . Thanks for the confirmation :slight_smile:

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