BPM for Warning Message on Duplicate PO

Good morning,

I am currently trying to create a BPM that will pop up a warning message when a duplicate PO is used on a Sales Order, but will not stop the user from entering the PO number as we have customers that will re-order products using the same PO. We are using Epicor 10.1.400.0 currently and I’ve tried to write the BPM on the SalesOrder.MasterUpdate method directive. I can get it to where the message will pop up but it will show on everything that is put in the PO box instead of just on duplication. I’ve tried using the “Number of rows in the query” condition and have added:

CustNum=OrderHed.CustNum field
and PONum=OrderHed.PONum field

I’ve seen other users say to add
OrderNum <>OrderHed.OrderNum field

I’ve tried that and the message will no longer show.

Any suggestions on how I can do this differently? I’m still fairly new to BPMs so any advice is much appreciated!

Can you send some screenshots of your BPM setup;

Epicor has built in functionality for this each customer to enable. you have to checked on customer screen.

1 Like

I know that we can check the box on the Customer Setup but that is a hard stop on a duplicate PO. We’re just looking for a warning. Thank you for any help!

You need to use the ttTable for your criteria. Not the ORderHed.CustNum but ttOrderHed.CustNum (same for the PO) Try that.

You may have to drag in ttORderHed on those fields.

Thank you so much! Dragging in the ttOrderHed took care of that.

1 Like

I am trying to put a date range on this BPM so that it will only fire if the PO number has been used in the last 90 days. So if the PO was used beyond the 90 days we won’t get that warning message. I’ve been playing around with the BPM and just cannot get it to do what I’m trying to do. Would you have any tips? I’ve tried adding a second line on the condition with an “OrderDate=ttOrderHed” and played around with the less than, not less than, etc wording. I’ve also tried the specified time frame option but I wasn’t doing something right there and it wouldn’t work either. Thank you for any tips you might have!

Just a note, maybe not in your case…but for me, when I make a change in the BPM, (not all the time but sometimes… ) it behaves as if my changes are not working. I need to perform a recycle IIS in order to make the changes work.

As well, I place some messages in the bpm in order to see if my changes are in effect…

Pierre

I will definitely keep that in mind. I know when I was playing around with it, depending on what I did the warning would show up at times and wouldn’t at other times but it was never a sometimes it worked sometimes it didn’t situation.

Have you tried BPM Directive Recompile instead of bouncing your entire appserver?

System Management > Business Process Management > Directive Update > Directive Recompile

Try this as an in-transaction data directive on OrderHed
/* TO DO: replace object variables with typed variables. Add reference if necessary.*/
object THROW_PRIVATE = null;
int vExistOrder = 0;
Erp.Tables.OrderHed OrderHed;
var ttOrderHed_xRow = (from ttOrderHed_Row in ttOrderHed
where string.Equals(ttOrderHed_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase)
select ttOrderHed_Row).FirstOrDefault();
if (ttOrderHed_xRow != null)
{
OrderHed = (from OrderHed_Row in Db.OrderHed
where (string.Compare(OrderHed_Row.Company, ttOrderHed_xRow.Company, true) == 0) && (OrderHed_Row.OrderNum != ttOrderHed_xRow.OrderNum) && (string.Compare(OrderHed_Row.PONum, ttOrderHed_xRow.PONum, true) == 0) && (OrderHed_Row.CustNum == ttOrderHed_xRow.CustNum)
select OrderHed_Row).FirstOrDefault();
if (OrderHed != null)
{
vExistOrder = OrderHed.OrderNum;
CallContext.Current.ExceptionManager.AddBLException("Existing Order uses this PO. OrderNo: " + Compatibility.Convert.ToString(vExistOrder));
THROW_PRIVATE = null;
}
}

I have never tried the recompile but will try it in the morning. Does that just refresh the BPM?

This code is much more advanced than anything I’ve tried but I’m definitely willing to give it a shot! Would I add this in place of what I already have? Or on top of it?

It actually recompiles the BPM at the code level, and in doing so flushes anything that may be cached or stuck or leftover (I know those aren’t programming terms, but I’m not a programmer). Whenever I’ve had BPMs acting funny after playing with one for awhile, running a recompile seems to soothe my savage server.

That makes sense to me! I’m going to do the recompile this morning. I’m working in a test environment so at least if I do something that screws it up it won’t hurt the live database. Thank you!

Hi @SueLowden I’ve tried using the “Execute Custom Code” option and copy and pasting this into that. I configured it to use the code synchronously and it gives me this error: Error CS0103: The name ‘Compatibility’ does not exist in the current context [InTran.DUPLICATE_PO_CHE.cs(78,96)]

Am I adding this in the correct place? Should I change it to asynchronously?

Hi
Remove the Compatibility bit from the script and give that a go - however if you are on a newish version of E10 you may find an option on the Customer record without having tocode

1 Like

I’m still struggling to add a date range on this BPM, does anyone have any ideas on how to have the BPM only fire if the PO has been used in the last 90 days?

You should be able to add a condition. “the number of rows in the defined query is equal to 0” or whatever it’s called. You can design your query to join the PO number from the TT table to the sales order, and limit the sales order to a date range > today - 90 days.