Solved

PO Order Cancel through code

  • 10 August 2021
  • 4 replies
  • 122 views

Userlevel 4
Badge +1

I have a requirement to cancel the PO,  from a customization screenbased on the business logic. We have tried implementing the below code  but no luck.

 POOrderEntry docgraph = PXGraph.CreateInstance<POOrderEntry>();

 docgraph.Document.Current = ItemList;  // Item List is current PO 

docgraph.Document.Update(docgraph.Document.Current);

docgraph.Cancel.Press();

Can some one help me on this?

icon

Best answer by Vinay Koppula 10 August 2021, 14:47

View original

4 replies

Userlevel 5
Badge +1

Hi @deebhane,

 

Just try to update the status field and check. 

 

 POOrderEntry docgraph = PXGraph.CreateInstance<POOrderEntry>();

 docgraph.Document.Current = ItemList;  // Item List is current PO 

docgraph.Document.Current.Status = POOrderStatus.Cancelled;

docgraph.Document.Current.Cancelled = true;

docgraph.Document.Cache.Update(docgraph.Document.Current);

docgraph.Actions.PressSave();

 

Thanks, 

Vinay

Userlevel 6
Badge +4

Try this.  The action in 2021R1 appears to be CancelOrder.  Also, I prefer using Search to find the record.  I think the issue specifically causing your issue is that you did not save after invoking the action.

POOrderEntry docgraph = PXGraph.CreateInstance<POOrderEntry>();
docgraph.Document.Current =
docgraph.Document.Search<order.orderType,order.orderNbr>
(ItemList.OrderType, ItemList.OrderNbr);
docgraph.CancelOrder.Press();
docgraph.Save.Press();

 

Userlevel 4
Badge +1

Thanks  @Vinay K  the  above suggestion worked.  @brianstevens  Since I was looking for a solution in 20R2. @Vinay K  approach worked. Thanks for your suggestions. 

Userlevel 5
Badge +1

Thanks for the confirmation @deebhane

Happy Coding! 

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