Skip to main content

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.

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