I am doing customization in Sales Order and I want to customize the action Cancel Order. I reflected the code but could only find this:
public PXAction<SOOrder> cancelled;
[PXUIField(Visible = false)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
protected virtual IEnumerable Cancelled(PXAdapter adapter)
{
return adapter.Get();
}
Is it the right function to customize?
It's a pretty good question because it involves more than just the business logic layer.
SOOrderEntry is a pretty powerful and complicated page that must handle multiple states. To do so, Acumatica Framework has an Automation Module that allows to set different values depending of the current state. When you click on Cancel Order, the framework triggers a state change defined in the page Automation Definitions (SM205010) and Automation Steps (SM205000). Look at the definition of the action Cancel Order below.
You can see that on clicking the button, some field are changed. Please note that the field Cancelled is set to True. The field Cancelled is a bound field of SOOrder with the following definition:
Now that we understand that a Field has been changed, we can look for event handlers that would handle this change. There is currently an event handler (FieldVerifying) that would ensure the order can be canceled before doing so. If you want to extend the validation logic you can customize this handler:
If you'd prefer to add an event that would occur if the cancelation succeeded, you can create a new event handler (FieldUpdated):
The code you found is only a placeholder to create a button and allow the framework to trigger the automation step when you press it.