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!