Skip to main content

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?

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


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();

 


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. 


Thanks for the confirmation @deebhane

Happy Coding! 


Reply