I’ve got some custom code in Erp.CustShip.GetByID that is supposed to check for some conditions to be true, and if so, display a message that shipping is not allowed and prevent shipping from occurring.
My understanding is that to throw the actual exception, I need to call CallContext.Current.ExceptionManager.AddBLException() with a string containing the error message. If I’m in Customer Shipment Entry with the test record already loaded and hit refresh, the exception comes up - but the record is still displayed, meaning that shipping is still possible. This isn’t a problem as this is just for testing and in production the record wouldn’t be up in the first place. It does show the BPM is otherwise functioning as expected and proves out the logic.
But if I clear the record and try to re-enter the packing slip number, it says “Record not found. Add new?” I assume the exception is somehow interfering and causing this, but I don’t even see my exception message!
I’ve tried this using both a pre-processing and post-processing method, but both have the same behavior.
int hardstop_reasons = 0;
/* logic to determine whether or not to throw exception omitted here... */
if (hardstop_reasons > 0) {
CallContext.Current.ExceptionManager.AddBLException("Hard Stop on Order");
}
I get the same behavior if I raise the exception using the “Raise Exception” widget.
(Annoyingly, I also don’t get any informational messages that are supposed to be displayed in the custom code block before the exception - it’s like an exception retroactively cancels such messages so they don’t pop up. Although, this behavior seems to occur whether the exception was in the custom code block or via a widget.)