I think I’ve been looking at this too long. 24r1
I have set ShipVia to be required through cache attached in my SOOrderEntry extension. I added Required = true to PXUIField and changed the PersistingCheck in PXDefault to NullOrBlank:
[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXUIField(DisplayName = "Ship Via", Required = true)]
[PXDefault(typeof(Search<Location.cCarrierID, Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>, And<Location.locationID, Equal<Current<SOOrder.customerLocationID>>, And<Current<SOOrder.behavior>, NotEqual<SOBehavior.bL>>>>>), PersistingCheck = PXPersistingCheck.NullOrBlank)]
protected virtual void _(Events.CacheAttached<SOOrder.shipVia> e)
{ }
So, in theory, I should not be able to save the record without supplying a shipvia value. But, I can click Remove Hold.
Now, the record is not persisted to the database, but the order is now Off Hold.
And I understand that’s because the action for taking the record off hold is to change the value of Hold to false. And then the action attempts to save the record. And it failed the save the record because of the missing data. But the record has already progressed past On Hold.
Now I’m thinking the best course of action is to put a handler for Hold_FieldUpdating so I can check if we’re trying to leave being on hold and make sure that all required fields have been filled in.
Am I overthinking this?