Skip to main content
Solved

PO Order Cancel through code


deebhane
Semi-Pro I
Forum|alt.badge.img+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?

Best answer by Vinay Koppula

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

View original
Did this topic help you find an answer to your question?

4 replies

Vinay Koppula
Semi-Pro II
Forum|alt.badge.img+1
  • Semi-Pro II
  • 125 replies
  • Answer
  • August 10, 2021

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


Forum|alt.badge.img+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();

 


deebhane
Semi-Pro I
Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • 62 replies
  • August 11, 2021

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. 


Vinay Koppula
Semi-Pro II
Forum|alt.badge.img+1

Thanks for the confirmation @deebhane

Happy Coding! 


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