Skip to main content

Hello Everyone,

 

We have a requirement to add a popup validation message on the “Remove Hold” action in the Change Order screen. If a specific condition is met, we need to throw an exception so that the Change Order remains in “On Hold” status until the user corrects the values.

 

We are able to display a popup warning message on the screen using `View.Ask("")`, and it’s working fine. However, once the user clicks “OK” on the popup, the status changes to “Pending Approval.” If we throw an error upon clicking "OK," the record appears as "On Hold" on the screen, but in the table, the “Hold” field changes to false.

 

We also tried bypassing the base method if our custom condition is met. In this case, the status on the page shows as “On Hold,” but in the backend, the “Hold” field still becomes false, preventing further edits.

 

Even when we simply throw a `PXException` in the “Remove Hold” action, the exception displays correctly, and the screen shows “On Hold” status, but the `Hold` field in the Change Order table changes to false.

 

We’re not sure why the backend “Hold” field changes to false, even though we’re throwing an exception and the status field appears as “On Hold.” Could you suggest any changes we should make to achieve the intended behavior?

 

Below is the code we have tried.

 

public class ChangeOrderEntry_Extension : PXGraphExtension<ChangeOrderEntry>
{
public static bool IsActive() => true;

public delegate IEnumerable RemoveHoldDelegate(PXAdapter adapter);
aPXOverride]
public IEnumerable RemoveHold(PXAdapter adapter, RemoveHoldDelegate baseMethod)
{
if (Base.Document.Current.ExtRefNbr == "Test12")
{
// Base.Document.Cache.IsDirty = true;
//throw new PXException("My Custom error message");


WebDialogResult result = Base.Document.Ask(ActionsMessages.Warning, PXMessages.LocalizeFormatNoPrefix("Change order error"),
PXMessages.LocalizeFormatNoPrefix("Please correct the Ext ref nbr."),
MessageButtons.OK, MessageIcon.Warning);
//throw new Exception();
// return null;
if (result == WebDialogResult.OK)
{
Base.Document.Cache.IsDirty = true;
return adapter.Get();
//throw new PXException();
}
// return adapter.Get();
}
//else
// {
var baseResult = baseMethod(adapter);
return baseResult;
// }
}


}

 

I have seen that in the OrderEntry screen the setting of the Canceled field is done by the workflow engine regardless of the results of CancelOrder action. To add a validation step in that process I had to add a check in a PrePersist override. If the validation failed, I would set the Canceled field to false and throw an exception - thus preventing the order cancel and resetting the field changed by the workflow engine.

Your issue sounds like it is the same problem.


Reply