Skip to main content
Solved

Call checks and Payments item via Event

  • January 20, 2022
  • 5 replies
  • 75 views

Forum|alt.badge.img+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 ?

Best answer by jinin

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();
        }
    }

5 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • Answer
  • January 21, 2022

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();
        }
    }


Forum|alt.badge.img+2
  • Author
  • Varsity I
  • January 21, 2022

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 ?


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • January 21, 2022

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();
        }

 


Forum|alt.badge.img+2
  • Author
  • Varsity I
  • January 21, 2022

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 


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • January 21, 2022

Great @Ivan . Thanks for the confirmation :slight_smile: