Here’s how I solved this problem:
I created a new action that executes the standard Release action behind the scenes, without regard for the user’s permissions. It is hidden by default.
public PXAction<ARInvoice> customRelease;
[PXButton(CommitChanges = true, IsLockedOnToolbar = true, Connotation = ActionConnotation.Success)]
[PXUIField(DisplayName = "Release", Visible = false)]
protected virtual IEnumerable CustomRelease(PXAdapter adapter)
{
return Base.Release(adapter);
}
In the RowSelected event for the Invoice, I perform my check and instead of attempting to enable the standard Release, I instead show my custom Release, as long as the Invoice has not yet been released AND the standard Release is not already enabled.
customRelease.SetVisible(hasAdjustmentSelected && !isReleaseEnabled && !(invoice.Released ?? false));
Works fancifully.