Access method name inside BPM

Hi Team,
Does anyone know if there is a way to access the name of the method being called inside code in a BPM?

Reason is I want to write code I can use in multiple BO’s for Update and Delete to track row changes but I don’t want to write a BPM for each BO just a generic one I can copy and paste and will work.

I could look at the row update/delete flag on the table being sent but accessing the method directive would be more reliable as most bo’s have multiple update rows.

Thanks
Pat

callContextClient has AssemblyName and ProcessID maybe those can help you.

This thread discusses them.

This should fix you up, at least until @josecgomez comes along and says there is something easier :rofl:

This is verbose, so people can see how it can be done. Clean up as needed.

  string messageText = "";

  //Your information is here:
  var thisAssembly = this.GetType().Assembly;
  
  //This next bit can obviosuly be done a bit different, I broke it out like this to show how to parse it.
  
  //Ice.BO.DynamicQuery.GetList,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null
  string assemblyFullNameUnfiltered = thisAssembly.FullName;
  
  //Ice.BO.DynamicQuery.GetList
  string assemblyFullNameFiltered = assemblyFullNameUnfiltered.Split(",")[0]; //Split on comma, get first item
  
  //.GetList
  string boMethod = assemblyFullNameFiltered.Substring(assemblyFullNameFiltered.LastIndexOf(".")); //Get the last index of the dot, get text from there, leave dot on
  
  //Ice.BO.DynamicQuery
  string businessObject = assemblyFullNameFiltered.TrimEnd(boMethod.ToCharArray()); //remove the method text from the end, the dot is still on so it pulls it all off
  
  //GetList
  boMethod = boMethod.TrimStart('.'); //Remove leading dot
  
  messageText += $"Assembly Full Name Complete: {assemblyFullNameUnfiltered}\n";
  messageText += $"Assembly Full Name Filtered: {assemblyFullNameFiltered}\n";
  messageText += $"BO: {businessObject}\n";
  messageText += $"BO Method: {boMethod}\n";
  messageText += $"BO Method Type: {this.TypeName}\n";


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

Output:

Assembly Full Name Complete: Ice.BO.DynamicQuery.GetList,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null
Assembly Full Name Filtered: Ice.BO.DynamicQuery.GetList
BO: Ice.BO.DynamicQuery
BO Method: GetList
BO Method Type: PreProcessing

Very helpful for seeing who is calling the BO, but if I’m understanding correctly, he
wants to see which BO he is currently inside.

Here is another way, query the Db with LINQ for the directive ID:

I did not test speed on any of these methods.

(Also verbose :rofl: )

  string messageText = "";
  
  //Query Db for this directive ID (this.Id)
  BpDirective thisBPDirective = Db.BpDirective.Where(bpd => bpd.DirectiveID == this.Id).First();
  
  //Get Assembly Name
  string assemblyFullName = thisBPDirective.BpMethodCode;
  
  //.GetList
  string boMethod = assemblyFullName.Substring(assemblyFullName.LastIndexOf(".")); //Get the last index of the dot, get text from there, leave dot on
  
  //Ice.BO.DynamicQuery
  string businessObject = assemblyFullName.TrimEnd(boMethod.ToCharArray()); //remove the method text from the end, the dot is still on so it pulls it all off
  
  //GetList
  boMethod = boMethod.TrimStart('.'); //Remove leading dot
  
  messageText += $"Assembly Full Name: {assemblyFullName}\n";
  messageText += $"BO: {businessObject}\n";
  messageText += $"BO Method: {boMethod}\n";
  messageText += $"BO Method Type: {this.TypeName}\n";


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

Output:

Assembly Full Name: Ice.BO.DynamicQuery.GetList
BO: Ice.BO.DynamicQuery
BO Method: GetList
BO Method Type: PreProcessing

You can see the BO, but discerning the method is not possible. You can get the customization name.

image

Last one, I promise :rofl:
I’m bored and I don’t want to vacuum the pool, it’s HOT outside! :dumpster_fire:

Edit: I did clean my pool, swam, and grilled food. Very productive day.
Not sure how I don’t look like a lobster.

Query the Business Object with the ID of the directive you are in.
Again, no speed tests done.

  string messageText = "";
  
  //Query the business object for this directive ID (this.Id)
  //This is already referenced in all BP Methods
  BpDirectiveRow thisBpDirectiveRow = null;
  CallService<Ice.Contracts.BpMethodSvcContract>(bpMethods =>
  {
      bool morePages = false;
      thisBpDirectiveRow = bpMethods.GetRows("", "", $"DirectiveID = '{this.Id.ToString()}'", 0, 0, out morePages).BpDirective.First();
  });
  
  
  //Get Assembly Name
  string assemblyFullName = thisBpDirectiveRow.BpMethodCode;
  
  //.GetList
  string boMethod = assemblyFullName.Substring(assemblyFullName.LastIndexOf(".")); //Get the last index of the dot, get text from there, leave dot on
  
  //Ice.BO.DynamicQuery
  string businessObject = assemblyFullName.TrimEnd(boMethod.ToCharArray()); //remove the method text from the end, the dot is still on so it pulls it all off
  
  //GetList
  boMethod = boMethod.TrimStart('.'); //Remove leading dot
  
  messageText += $"Assembly Full Name: {assemblyFullName}\n";
  messageText += $"BO: {businessObject}\n";
  messageText += $"BO Method: {boMethod}\n";
  messageText += $"BO Method Type: {this.TypeName}\n";


  this.PublishInfoMessage(messageText, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
Assembly Full Name: Ice.BO.DynamicQuery.GetList
BO: Ice.BO.DynamicQuery
BO Method: GetList
BO Method Type: PreProcessing
1 Like

awesome thanks Kev!