Question

Unable to Perform Void action in Payments and Applications screen through code in 21R2

  • 27 October 2021
  • 1 reply
  • 91 views

Userlevel 1

Hello Everyone,

In 21R2 version, when trying to do Void Payment in ‘Payments and Applications’ screen from code, facing below error where as same is working fine when tried from screen.

Used below code snippet for the void action, which worked in 20R2 version.

Code Snippet:

ARPaymentEntry graph = PXGraph.CreateInstance<ARPaymentEntry>();

 graph.Document.Current = payment;

 if (graph.Document.Current != null && graph.Document.Current.Status != "V")

  {

                    if (graph.Actions.Contains("VoidCheck"))

                    {

                        graph.Actions["VoidCheck"].Press();

                        //var result = graph.VoidCheck(new PXAdapter(graph.Document));

                        graph.Persist();

                    }

                    if (graph.Actions.Contains("Release"))

                        graph.Actions["Release"].Press();

                    graph.Clear();

                }

}

Note: Tried with commented statement as well.

Error:

Below is the error response after executing 'graph.Actions["VoidCheck"].Press();' statement.

 

Please let me know if any thing missed here or any one faced this before. 

 

Thanks in advance.


1 reply

Userlevel 4
Badge

Hello @vidyakeerthik 

I was testing the same code, and I found another post; Call Void action for Checks and Payment item | Community (acumatica.com)

 

This is my code, catching the redirect exception.

 

  ARPayment sPayment = ARPayment.PK.Find(graphSO, payment.AdjgDocType, payment.AdjgRefNbr);

if (sPayment.Status != "V") //Voided
{
//Void payment

ARPaymentEntry graphPA = PXGraph.CreateInstance<ARPaymentEntry>();
try
{
graphPA.Document.Cache.Current = sPayment;

graphPA.voidCheck.Press();
}
catch (PXRedirectRequiredException ex)
{
//Release voided payment
ARPayment voidPayment = graphPA.Document.Search<ARPayment.refNbr>(sPayment.RefNbr, ARPaymentType.GetVoidingARDocType(sPayment.DocType));
if (voidPayment != null)
{
graphPA.Document.Current = voidPayment;
if (voidPayment.Status == ARDocStatus.Hold)
{
graphPA.releaseFromHold.Press();
}
graphPA.release.Press();

}
}


}

 

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