Prevent Closing (Voiding) Sales Order, Line, or Release when open release is tied to a PO

When a line on a sales order is marked buy to order and is linked to a PO, you cannot change the part number. You cannot reduce the SO line quantity to less than the Linked PO Release Quantity:
image

If you want to increase the SO line quantity you get a message to notify Purchasing.
image

If the user fails to notify purchasing, a new PO suggestion will be created anyway for the additional quantity needed.

This all works as I think it should.

Here is the problem. A sales order release (that is marked BTO) can be manually closed by the sales team, even if it is already linked to a PO (without a message or anything).

If EPICOR will not let you reduce the SO quantity on a BTO line linked to a PO, why does Epicor let a salesperson CLOSE a SO release (essentially reducing the quantity to 0) that is marked BTO and linked to a PO? Epicor says this is the way it has worked for a long time, so they claim it is working as intended.

I would like to prevent a user from closing an Order, Line, or Release that has at least 1 open release that is linked to a PO.

I have run a trace and have seen the Methods as CloseOrder, CloseOrderLine, or CloseRelease.

What is the best way to prevent a user from closing an Order, Line, or Release that has at least 1 open release that is linked to a PO? I have tried a pre-processing MethodDirective (starting with CloseOrder) and I was still able to close the order.

What did you do in that directive? You’ll need to abort in some way.

bool myCondition = true;

if(myCondition)
{
    InfoMessage.Publish("Nope");
    MarkCallCompleted();
}

On my Erp.BO.SalesOrder.CloseOrder - preprocessing method directive, I put in the condition: “Number of rows in the Query is more or equal to 1”.
The query links the result.OrderHed table to the ERP.OrderRel with the criteria on the OrderRel as OpenRelease = true and PONum > 0.

That should work you would think with the Exception, but I have seen it not before in another BPM.

Did the exception fire?

If it did, and it continued, replace it with a message block and a “Complete Method Call” block.

The message in the exception did not pop-up.

Then something is wrong with your query.

I’d be linking result.OrderHed with result.OrderRel since they are both already there.

I have a BAQ with the Erp.OrderHed table linked to the Erp.OrderRel, using the same criteria on the Release (the criteria on the OrderHed is = to the order number I am testing.

The results do show one line.

Output a message from that query in the method directive and see what’s up.

Kevin, you were right…my query was not returning results, so this is how I changed it:

I am not sure what iOrderNum is, but it worked for this method. iOrderNum did show up in the trace:

It seems to be working now. Thank you.

It’s the current ordernum you are trying to close. You did good.

Now remember to do the line and the release methods as well.

Kevin,
Yep, I am working on those too, but thank you for the helpful reminder.

Do you know if this will “screw up” any standard process in Epicor (like when an order, line, or release gets closed by another method)?

If they match the conditions you set up, and they close it via this method, then yes it will.

However I don’t think you’ve done anything you don’t want stopped anyway.

If you come across something, address it then.

Number 1 thing. Document

A strange thing is occuring. I have a leftover informational message, but for some reason, Epicor seems to skip this message and jump right to my Exception message:

But this is the only popup (my exception message) when I try to Close the Order:
image

Why would my informational message get skipped?

It’s a consequence of the UI architecture.

I would remove the exception and just use the message box, then chain a “Complete Method Call” block.

Kevin,
In an effort for me to learn, what makes the message box + Complete Method Call better than the raise exception that “Terminates on Error”?
Brian

Here is a new wrinkle. I wanted to allow users to void a line even if a PO is suggested, but not yet created. A user can delete a line after a PO is suggested but not yet linked and then if the buyer tries to generate a PO for that deleted line, they get an error that the suggestion is no longer valid. For pending suggestions, it seems like Epicor only evaluates if the “line/release to be ordered” has been deleted but does not care if it has been voided.

I guess I will need to change my queries, but not sure what the flag is called for PO Suggested?

Nothing. Just my preference here. I figured you wanted a “nicer” message than an exception.

Result is the same.

You’re stepping a little out of my comfort zone. Maybe someone else can field that one.