Help required with two step BPM on Sales Order

Took me a while to find the right business object but through postings on the form I’ve used the tracing log to verify.

My goal is to only allow parts to be entered into a SO where the part is ready to be sold in just the one currently active site. I am determining the part as good to be sold by adding “PRT-AFM” to the part durometer field. If it contains that string then good to be sold. The BPM seems to be executing but produces an error. The error:

For Searchability

BPM runtime caught an unexpected exception of 'ArgumentException' type.
See more info in the Inner Exception section of Exception Details.

Exception caught in: Epicor.ServiceModel

Error Detail 
============
Description:  BPM runtime caught an unexpected exception of 'ArgumentException' type.
See more info in the Inner Exception section of Exception Details.
Program:  System.dll
Method:  ScanRegex
Original Exception Type:  ArgumentException
Framework Method:  <C001_QuerySizeCondition>b__2_4
Framework Line Number:  0
Framework Column Number:  0
Framework Source:  <C001_QuerySizeCondition>b__2_4 at offset 38 in file:line:column <filename unknown>:0:0


Client Stack Trace 
==================
   at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
   at Erp.Proxy.BO.SalesOrderImpl.MasterUpdate(Boolean lCheckForOrderChangedMsg, Boolean lcheckForResponse, String cTableName, Int32 iCustNum, Int32 iOrderNum, Boolean lweLicensed, Boolean& lContinue, String& cResponseMsg, String& cCreditShipAction, String& cDisplayMsg, String& cCompliantMsg, String& cResponseMsgOrdRel, String& cAgingMessage, SalesOrderDataSet ds)
   at Erp.Adapters.SalesOrderAdapter.MasterUpdate(Boolean lCheckForOrderChangedMsg, Boolean lcheckForResponse, String cTableName, Int32 iCustNum, Int32 iOrderNum, Boolean lweLicensed, Boolean& lContinue, String& cResponseMsg, String& cCreditShipAction, String& cDisplayMsg, String& cCompliantMsg, String& cResponseMsgOrdRel, String& cAgingMessage)
   at Erp.UI.App.SalesOrderEntry.Transaction.Update()

Inner Exception 
===============
parsing "*PRT-AFM*" - Quantifier {x,y} following nothing.

My BPM

image

The BPM query

Any help appreciated

Try using SalesOrder.Update instead of MasterUpdate.
OR you could use a data directive instead… that way it will catch the problem no matter WHICH process created the line… for example, if you convert a QUote to an Order, it will not use the SalesOrder.Update or MasterUpdate. It uses a different method… but no matter what, the OrderDtl.Update WILL run as a data directive in either case.

Thanks Tim. I will give that a go.

This error:

Lead me to another post on the forum

Choosing a hypen in a filter string will be the end of me…

I can get this to work with MATCHES ".*AFM.*"

Did this not work?

.*PRT-AFM.*

Not quite but your post did help with looking at Microsoft c# regex posts. I think things were working but testing against parts I should be able to work with also produced an error.

Hypen in regex is a special character so most posts state to”escape” it. I now know how to search for characters formatted social security numbers now though!

I am going with this:

"/.*PRT.AFM.*/"

Starting & ending " is required to enter a clause within the query in the BPM

/ is the start & end identifiers for regex
. matches any one character
* matches and number of characters
PRT is one half of the text string I want to find
. any one character
AFM the other half
.* any one then any number

So this will now match PRT-AFM but also

PRT?AFM
PRTdAFM
PRT AFM etc

useful resource on this for building regex expressions

I have tried many different valid regex expressions to capture the hyphen but I am assuming Epicor does not recognise all of them. Also, being new to Regex it seems different programming languages have their own syntax.

End result - TESTPART-S2 is not allowed

You could also get around this by executing a code widget and use C#'s contains method.

Thanks Aaron. We are short on C# coding skills current but will bear this in mind for when I have some time to work on that

I can help you out on Monday.
What’s the goal?

You’re linking the OrderDtl table to the Part table to see if the Durometer field contains “PRT-AFM”?

Correct on requirement. Orddtl or added/changed row and see if field contains PRT-AFM

Thanks Aaron

So, for your condition block, change it to “If custom code is valid” and add this in the code blocl:

var tt = ttOrderDtl.FirstOrDefault(r=>r.Added() || r.Updated() );

if( tt != null )
{
  string partNum = tt.PartNum;
  string duroField = (
    from p in Db.Part.With(LockHint.NoLock)
    where p.Company == Session.CompanyID &&
          p.PartNum == partNum
    select p.Durometer).DefaultIfEmpty("").FirstOrDefault();
    
    
  if( duroField.Contains("PRT-AFM") )
    return true;
  
}

return false;

Let me know how that works out.

1 Like

Thanks alot for this Aaron. I have a few month end issues then will look to test.

Regards

1 Like

Yep, that did it. Thanks Aaron, appreciate it.

1 Like