Skip to main content
Question

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

  • October 27, 2021
  • 1 reply
  • 112 views

vidyakeerthik
Freshman II
Forum|alt.badge.img

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

anahizentella94
Jr Varsity III
Forum|alt.badge.img

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


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