Prevent Order Form Closing Order If Data Not Set

Hey there,

I’m wanting to check a field (in this case OrderHed.ReadyToCalc) when the user navigates away from the order by closing the form, moving to another order, clearing the form, etc. and to either prevent leaving the form until it’s set or to set the field to true and update it.

In a BeforeAdapter on the sales order, I can catch it on the way out with args.MethodName == “CheckMakeDirectReleases”, but:

I’ve tried setting the field to true and oTrans.Update at that point, but that does odd things.

I’ve tried ‘arg.Cancel = true;’, but it seems to be ignored.

I’ve tried ‘throw new Ice.BLException(“Ready To Process must be set”);’. I get the message, but the exception is ignored.

My option seems to be to trap every exit from the order, like file/exit, exit button, navigate bar, change the order number, click the Order… button, etc. That seems to be overkill.

Any advice?

Thanks,

Joe

Maybe there’s a better way to accomplish the task than a bunch of complex UI code?

That would be helpful. :slight_smile:

I just need to make sure the ReadyToCalc field is set to true before the form exits. The dataset might or might not be in a dirty state. If it’s not, there’s no update to catch it in a BPM, and even then the user can decline the update at the . I’m open to suggestion.

Thanks,

Joe

Does the ReadyToCalc field need to be set to true prior to exit whether the user wants that or not?

Yes, that’s what the customer wants so the booking table will always update.

1 Like

Can you set it to true on the first time the user creates a sales order? That would force an update, but would definitely set the field. Could probably do it BPM side too

Yes, it’s on by default when the order is created. It’s a long story, but there’s configuration going on where additional lines are created in a customer-created dll. When those are done with the flag on we get double bookings, so we are turning it off when we start the configuration.

It seems the flag needs to be turned back off in the form and not in a BPM (where it would be really handy) for the bookings to work right.

Currently I don’t have a good way to know in the order form that the configurator has run (I’ve tried really hard to figure that one out, believe me). Otherwise, I would just turn the flag back on when it returns.

That gives me an idea. Maybe I’ll just check in the order detail epidataview notification if the flag is off and just set it there. Hmm. Testing…

Thanks,

Joe

We are working on a similar scenario with counter sale so we can prevent the form from closing when counter sale is checked and pack is also checked. We want our users to uncheck pack and leave order on hold when still keeping counter sale box checked before form can be closed.

Here is a snippit of our code. Our developer used the wizard to setup the sales order form closing.

private void SalesOrderForm_Closing(object sender, System.ComponentModel.CancelEventArgs args)
{
// Add Event Handler Code
EpiDataView edvOrderHed = ((EpiDataView)(this.oTrans.EpiDataViews[“OrderHed”]));
System.Data.DataRow edvOrderHedRow = edvOrderHed.CurrentDataRow;
EpiDataView edvOrderDtl = ((EpiDataView)(this.oTrans.EpiDataViews[“OrderDtl”]));
System.Data.DataRow edvOrderDtlRow = edvOrderDtl.CurrentDataRow;
if ((edvOrderHedRow != null) && (Convert.ToBoolean(edvOrderHedRow[“CounterSale”])) && (Convert.ToBoolean(edvOrderHedRow[“CreatePackingSlip”])) && (Convert.ToBoolean(edvOrderHedRow[“OpenOrder”])) && (edvOrderDtlRow != null))
{
if (!ProcessUserCounterSale())
{
args.Cancel = true;
EpiMessageBox.Show(“Counter Sale Order has not been processed. To continue please do one of the following:\n1. Click Process Counter Sale button to complete sales order\nOr\n2. Uncheck Pack Slip checkbox and place order On Hold to process sales order later”);
}
}
}

Thanks, Kristine. We ended up doing something different, but all code is helpful!

Joe

Is that the full snippet? I tried copy/paste and it doesn’t work during compiling. It seems like it is being declared above somewhere and not sure where it is being declared in your snippet

Error: CS0103 - line 76 (387) - The name ‘ProcessCounterSale’ does not exist in the current context

ProcessUserCounterSale() looks like a function that she wrote. Seems like it automatically processes the counter sale, and returns true if the process succeeded . If not then set args.Cancel and show that message

Can I just delete that section of the code but still display a message?