Skip to main content
Solved

How to call a function based on change of PaymentMethod in Cash Sales screen

  • February 26, 2021
  • 6 replies
  • 177 views

Hi, 

I am new to acumatica and I am trying to do some customization

I have created a new payment method and would want to have create a function related to it. eg, on selecting the said payment method, a TextEdit to appear for input of a variable, a given action button to be enabled. On the Button Click, I want to query a table and return true or false. If true the save action to go through.

 

namespace PX.Objects.AR
{
  public class ARPaymentEntry_Extension : PXGraphExtension<ARPaymentEntry>
  {
    #region Event Handlers

    public PXAction<PX.Objects.AR.ARPayment> ProcessTemp;
  
    [PXButton(CommitChanges = true)]
    [PXUIField(DisplayName = "Process Temp")]
    protected void processTemp()
    {

    }



    #endregion
  }
}

 

Someone kindly help.

Dan

Best answer by Naveen Boga

Hi @doyuga,

 

Please find the below code and hope that helps you!!

 

  public PXAction<PX.Objects.AR.ARPayment> ProcessTemp;
        [PXButton()]
        [PXUIField(DisplayName = "Process Temp", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true)]
        protected virtual IEnumerable processTemp(PXAdapter adapter)
        {
            bool status = GetTemparatureDetails(Base.Document.Current.PaymentMethodID, Base.Document.Current.TempInputValue);
            if (status == false)
            {
                throw new PXException("Error");
            }

            return adapter.Get();
        }
        public bool GetTemparatureDetails(string PaymentMethod, string tempInput)
        {

            bool status = false;

            // logic here

            if (condtion)
            {
                status = true;
            }
            else
            {
                status = false;
            }

            return status;            
        }

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

6 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3410 replies
  • February 26, 2021

Hi @doyuga,

 

Can you please provide details on the “Process Temp” action? What exactly you wanted to do on this button click.

 

 


  • Author
  • Freshman I
  • 4 replies
  • February 26, 2021

I would want it to call a function while passing passing the parameters(paymentmethod,Tempinput, and the amount). The function to return true or false. If the function returns true, then the save process goes through else the save process raises exception.


  • Author
  • Freshman I
  • 4 replies
  • February 26, 2021
Naveen B wrote:

Hi @doyuga,

 

Can you please provide details on the “Process Temp” action? What exactly you wanted to do on this button click.

 

 

 

I would want it to call a function while passing passing the parameters(paymentmethod,Tempinput, and the amount). The function to return true or false. If the function returns true, then the save process goes through else the save process raises exception.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3410 replies
  • Answer
  • February 26, 2021

Hi @doyuga,

 

Please find the below code and hope that helps you!!

 

  public PXAction<PX.Objects.AR.ARPayment> ProcessTemp;
        [PXButton()]
        [PXUIField(DisplayName = "Process Temp", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true)]
        protected virtual IEnumerable processTemp(PXAdapter adapter)
        {
            bool status = GetTemparatureDetails(Base.Document.Current.PaymentMethodID, Base.Document.Current.TempInputValue);
            if (status == false)
            {
                throw new PXException("Error");
            }

            return adapter.Get();
        }
        public bool GetTemparatureDetails(string PaymentMethod, string tempInput)
        {

            bool status = false;

            // logic here

            if (condtion)
            {
                status = true;
            }
            else
            {
                status = false;
            }

            return status;            
        }


  • Author
  • Freshman I
  • 4 replies
  • February 26, 2021
Naveen B wrote:

Hi @doyuga,

 

Please find the below code and hope that helps you!!

 

  public PXAction<PX.Objects.AR.ARPayment> ProcessTemp;
        [PXButton()]
        [PXUIField(DisplayName = "Process Temp", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true)]
        protected virtual IEnumerable processTemp(PXAdapter adapter)
        {
            bool status = GetTemparatureDetails(Base.Document.Current.PaymentMethodID, Base.Document.Current.TempInputValue);
            if (status == false)
            {
                throw new PXException("Error");
            }

            return adapter.Get();
        }
        public bool GetTemparatureDetails(string PaymentMethod, string tempInput)
        {

            bool status = false;

            // logic here

            if (condtion)
            {
                status = true;
            }
            else
            {
                status = false;
            }

            return status;            
        }

 

Thanks Naveen for great help.

My tempinput field is not recognized as part of current document, which property can i configure to make it recognizable. 

I would also wish, to apply a condition that if the paymentmethod is TEMP and status is false, then You cannot save that sales entry.

Thanks.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3410 replies
  • February 26, 2021

Hi @doyuga,

As “Temp Input” is a DAC extended column. Please use the below syntax to get that column.

 

Base.Document.Cureent.GetExtension<ARRegister>().UsrTempInput.


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