Solved

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

  • 26 February 2021
  • 6 replies
  • 165 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

icon

Best answer by Naveen Boga 26 February 2021, 06:37

View original

6 replies

Userlevel 7
Badge +17

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.

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.

Userlevel 7
Badge +17

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

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.

Userlevel 7
Badge +17

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


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