Identifying Origin of Code Execution from Function or BPM in Epicor

Hello EpicUsers,

How can I determine whether the current code execution is initiated from a function or from a BPM within Epicor?

For example, given the code snippet provided below where a message box is utilized, what methods or flags can be utilized to dynamically append a suffix indicating whether the message box originates from a “BPM” or a “Function”?

Func<String, String> IM = (message) =>
    //string msgFrom = "(BPM)";
    string msgFrom = "(Functions)";
    message.Replace(msgFrom,"") ;
    message += msgFrom;
    this.PublishInfoMessage(message, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
    return message;

Dnyanraj Patil

You would need to put that code in every function or every bpm so wouldn’t you just do your msgFrom string and call it good? You can use the “this” variable to get context of where you are at in EFX and BPMs though. This is what I do for building debugging strings. In efx I pass into this iSource = this.ToString() and in bpm I pass into this iSource = this.Id.ToString();

// Store the DirectiveTypes for later
var boTypes = new string[]{ "?", "Pre", "Base", "Post" };
var dbTypes = new string[]{ "InTrans", "OutOfTrans" };

// Determine if input is a GUID and if it's a valid BpDirective
Guid guidOut;
bool isGuid = Guid.TryParse(iSource, out guidOut);

// Handle BO, DT, DQ
  var bpDir = Db.BpDirective.Where(x => x.DirectiveID == guidOut).FirstOrDefault();
  if(bpDir != null)
    // Handle segment vars
    oDirectiveType = bpDir.Source;
    oMethod = bpDir.BpMethodCode.Substring(bpDir.BpMethodCode.LastIndexOf("/") + 1).Replace("_","-");
    oBpmType = (bpDir.Source == "DB") ? dbTypes[bpDir.DirectiveType] : boTypes[bpDir.DirectiveType];
    oBpmName = bpDir.Name.Replace(" ","_").Replace("/","-");
    oSource = $"{oMethod}/{oBpmType}/{oBpmName}";
// Handle EFX sources
else if(iSource.StartsWith("efx.", StringComparison.InvariantCultureIgnoreCase))
  var efxNamespace = iSource.Split(".");
  oSource = $"Efx/{efxNamespace[1]}/{efxNamespace[3].Replace("Impl","")}";
  oSource = iSource;

This is the result of that code in conjunction with some other logging code.


Hello @jgiese.wci,

Great!! I appreciate the solution that you provided.