General BPM Question

I have a Standard Data Directive where a popup is placed at the beginning of an “Enter Custom Code” element before anything is read from the “foreach”. See attached.
I have seen this code fail without displaying the popup, which seems impossible.
When the code runs successfully however, the popup displays. The failure is happening further down in the code.

Am I missing something fundamental about BPM or C# ?
Is it somehow looking ahead and deciding it will fail? I have never seen anyone/anything address this, and most scratch their heads.

Am I wrong in assuming that the C# code is executed from top down?
If so, I would be most appreciative if someone could explain it.
Also, the BPM itself has nothing that could fail before this block of code.


@ksturm In my experience Log.WriteEntry lines happen as the code executes, but message popups can be held until the entire bpm is done.

If it fails in a code block, I believe it rolls back the transaction so as to not mess up your DB.
You will not see any InfoMessage anywhere (even the first line) if it throws an exception.
It’s frustrating if you want to include debugging messages as popups.

I use Ice.Diagnostics.Log.WriteLine() which writes to the event viewer on the server.

Thanks Greg and Hanna! It is related to rollback, which would explain it.

You might want to add a try catch block and catch your exceptions, as well as send back any other contextual data.

Try-catch only gets you so far. Based on her screenshot, I’m assuming she’s getting some error and is trying to locate the step at which it crashes because you can get ambiguous stuff, including in the try-catch.

By using the Ice.Diagnostics.Log.WriteLine() it actually writes to the event viewer as it is happening, so you can add step messages to narrow down the line that is failing.

Eg.

Ice.Diagnostics.Log.WriteLine("Before Update: " + variableInfo);
BO.Update;
Ice.Diagnostics.Log.WriteLine("After Update: " + variableInfo);

Thanks again Hannah. I will use the Log.WriteLine. Inconvenient, but it is what I need.

1 Like

You bet.

This is another, cleaner way of doing it that allows you to turn it on and off in the appserver.config file, so you don’t need to go back and clean your code up by removing/commenting out the diagnostic lines.
I’m too lazy to set it up, honestly, lol. How to write your own trace logs - Experts’ Corner - Epicor User Help Forum (epiusers.help)

I’m sorry, I meant in addition to, not instead of.

1 Like