System error message displayed instead of designed message

I am seeing something odd on a BPM that I’ve never seen before, when using a “Raise Exception” widget. I have a Post-Processing BPM on JobEntry.GetByID method that I am using in Job Receipt to Inventory to warn users when trying to receive a Make-to-Job/Order job to inventory instead.

Using a Show Message widget, it works perfectly fine displaying the message that I entered, however that doesn’t stop the details from loading and they want a hard stop here. So I copied the message over to the Raise Exception widget and set it as the action after my condition is true. But in the Job Receipt to Inventory form, I get a generic “Invalid Job Number” error (shown in screenshot below), instead of my custom message.

image

Any ideas why this is happening and how I can get my custom message to show instead?

The raised exception is doing the correct thing, but I would like to give my users a more detailed message that tells them why it’s an “invalid” job within this screen (job I’m using to test comes up fine in Job Entry/Tracker and Job Receipt to Job).

At that point, it’s already done.

If you want to stop an action, do it in pre-processing.

My BPM doesn’t work in pre-processing as currently designed.

Is post-process the same reason why my Raise Exception message won’t display, instead of a generic error message? Everything else works perfectly, so I just want this to work, too.

Explain how it does work, we can probably help.

(For reference, this is the same BPM as in my last topic: Job Receipt to Inventory not Make-to-Stock warning BPM conundrum - #5 by d_inman )

BPM checks for two conditions:

  1. The callContextClient.AssemblyName field is equal to the “ERP.UI.RcptToInvEntry” expression, And…
  2. Number of rows in …designed query… is more or equal to 1

Query is:

image

When conditions are true, then raise exception.

Ok, what do you want to happen if those conditions are true?

Abort & Error

or

Continue and Warn

We don’t want the system then pulling in details for those jobs, so Abort & Error.

Then it’s time to move to pre.

You can sometimes do it in post, but you run into other issues:

Did the base do something I didn’t need? Do I need to back it out?

It’s just a retrieve… Ok, but now I’m in post, now I have to empty the datasets etc.

I copied everything as I had it in Post- to Pre-Processing, but now my condition widget containing the two conditions, always returns False.

What could be the difference that I need to make so that–I assume–the query returns the correct results as it was in Post-Processing?

It’s acting like in Pre-Processing the dataset is not there to compare against, so it’s always going to return 0 rows.

Explain your conditions in plain language for me.

@klincecum @d_inman I do something like this on PreProcessing of ReceiptsFromMfg.PreUpdate.

I took that and made a quick adaptation that should be close for this. I did test it one time for make to stock and make direct each and it worked. :slight_smile:

/* Check If make to Stock */


Ice.Diagnostics.Log.WriteEntry("in PT check Qty");

foreach (var ttPartTran_Row in ds.PartTran.Where(row => row.Company == Session.CompanyID && row.TranType == "MFG-STK" && !row.Unchanged()))
{

    bool anyMTS = Db.JobProd.Where(w=> w.Company == CompanyID && ttPartTran_Row.JobNum == w.JobNum && w.OrderNum == 0).Any();
    
    Ice.Diagnostics.Log.WriteEntry($"in issue FG {ttPartTran_Row.JobNum} ROWMOD {ttPartTran_Row.RowMod} ");
    
    if(anyMTS == false)
    {
        Ice.Diagnostics.Log.WriteEntry($"Check Job  {ttPartTran_Row.JobNum} any MTS is {anyMTS}");

               CallContext.Current.ExceptionManager.AddBLException("No Make To Stock Prod Links");
               
               ttPartTran_Row.ActTranQty = 0; // This stops the update if the exception keeps going since a quantity of zero fails the PreCheck
    }
}




1 Like

@gpayne thank you for putting this together.

Where did you include the code?

I created a Pre-processing directive on the ReceiptsFromMfg.PreUpdate, added a “Show Message” widget with “BPM Triggered” text to check that the BPM is firing, and then added an “Execute Custom Code” widget that I pasted your code into.

When I pulled into Job Receipt to Inventory a job with Make-to-Job demand link, it loaded all details without ever giving me any kind of message. Also tested with a job that has a Make-to-Order demand link with same results.

It runs when you click OK.

You’re talking about when you click the “From Job…” button to search for a job and then click OK there once a job is selected?

When you click OK, to do the job receipt PreUpdate is run to verify the transaction is good. This check is Before that and stops it if there are no make to stock jobprod links.

If you go thru the process to do a receipt it should stop or you can see the bpm progress in the event viewer on the server.

Gotcha.

I need it to happen before the details are pulled into the form, hence why I was doing it on the JobEntry.GetByID method, as indicated in the trace I ran on the form.

Do you know how I can compare the JobNum parameter to the details on the JobProd table, so that I can check for an OrderNum or TargetJobNum on that table for the related Job?

Here’s the trace details:

<tracePacket>
  <businessObject>Erp.Proxy.BO.JobEntryImpl</businessObject>
  <methodName>GetByID</methodName>
  <appServerUri>deleted for privacy</appServerUri>
  <returnType>Erp.BO.JobEntryDataSet</returnType>
  <localTime>3/24/2023 13:33:34:2974161 PM</localTime>
  <threadID>1</threadID>
  <correlationId>69734985-ce57-43bb-b2c2-538047af57f0</correlationId>
  <executionTime total="2578" roundTrip="2566" channel="0" bpm="0" bpmDataForm="0" other="12" />
  <retries>0</retries>
  <parameters>
    <parameter name="jobNum" type="System.String"><![CDATA[294119]]></parameter>
  </parameters>
</tracePacket>

Disregard. I got the conditions to trigger correctly, but for some reason I’m still getting the generic-looking “Invalid Job Number” error message when I add a “Raise Exception” widget to the BPM, instead of my designed message.

Your stop is causing the Job Number to not get filled, but their message will override yours.

I tend to just take what Epicor will allow cleanly rather than getting in the middle of their background processing.