Troubleshooting BPM C# with popups?

When I create a new part and firm it we want an alert to fire for certain types of parts. The following simple BPM code is run.
If I look up email addresses in the user codes table instead of hard-coding them, I get an error.

What I really would like to know is how to pop open an alert whilst I’m troubleshooting to see how far the code is making it before it bombs. It’s something I do in other languages but don’t know how in Epicor code.

// Determine if an email is required.
// Only parts with Top40Job_c or ProblemJob_c need an email alert
// email will be based on the plant

callContextBpmData.Character01 = "";  // to email
callContextBpmData.Character02 = "";  // job meta info

var jh = ttJobHead.FirstOrDefault();

// find engineering user code - to address is LongDesc
// user code is specific to the company / plant 
  var usercode = ( from e in Db.UDCodes.With(LockHint.NoLock)
               where e.Company    == jh.Company 
               &&    e.CodeTypeID.ToUpper() == jh.Plant.ToUpper()
               &&    e.CodeID     == "ENG"
               select e).FirstOrDefault();         

//how can I pop open a message box here with something? How do you pop open message boxes in C# code? Something like a javascript alert('here'); so I can see where the code is and how far it gets?
// determine if part requires an email alert
  var part = ( from p in Db.Part.With(LockHint.NoLock)
         where p.Company == jh.Company 
         &&    p.PartNum == jh.PartNum
         select p).FirstOrDefault();

  if ( (part.Top40Job_c || part.ProblemJob_c) && jh.JobFirm ) {
if ( part.Top40Job_c ) {
  callContextBpmData.Character02 += " -top 40 job "; 
if ( part.ProblemJob_c ) { 
  callContextBpmData.Character02 += " -problem job ";
callContextBpmData.Character01 = usercode.LongDesc.ToString();


Perhaps something ala:

//some code you expect might fail
//BPM message box code here

Another option is using code to write directly to the server event log.

I think he wants to know what is the syntax of:

//BPM message box code here

@smason - Just about any C# code will work. Google: c# messagebox

here’s a good link for the basics

Correct. I’ve tried a bunch of different things that I’ve found on stack overflow and github but nothing seems to work or I don’t have the correct references or I’m not instantiating a message box. I don’t know what I need to be “Included” or how to include it.

I tried to add:
I get syntax error: The name ‘MessageBox’ does not exist in the current context. I get that error a lot. I’m unsure of how to add dependencies that I guess C# requires.

I constantly have to re-look up how to do it. Let me check my code to see what I’ve used.

BPMs run at the server, so if the code did run, you wouldn’t see it at your client. That’s why BPMs have a message widget that passes that back to the client.

I would go with Chris’s suggestion and use logging.

1 Like

I just used this recently, I always have to refer back to it.


Here’s a way from one of Chris’s other solutions:

this.PublishInfoMessage("yourstringhere", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");

1 Like

That worked pretty good. I guess that is how you do it. Thank you.

I knew Epicor must have had their own way to do it. Regular C# tutorials don’t mention that at all. Are there any C# Epicor BPM video tutorials? I can usually figure out the C# syntax but just not the Epicor way.

1 Like

Good deal! This forum is the best/only place that I know of.

For anyone in the future that needs to do this. You can try this:

// setup message box parameters: mbp
  var mbp1 = "This is my message";  // text to appear on popup
  var mbp2 = Ice.Common.BusinessObjectMessageType.Information; //req'd don't change
  var mbp3 = Ice.Bpm.InfoMessageDisplayMode.Individual;
  var mbp4 = ""; // text that appears in popup Details button ->program field
  var mbp5 = ""; // text that appears in popup Details button ->method field

// call popup message
  this.PublishInfoMessage(mbp1, mbp2, mbp3, mbp4, mbp5);