BPM on Button Click Event

Hi @dr_dan
I have copied my BPM above.
It starts with a simple MessageBox. I always do this to make sure the function is being called.
But it does not hit the MessageBox at all.

string msg ="Test";

string jobnum = "";
string company = "";
int ordernum = 0;
string CustName_c    ="";
string Address1_c    ="";
string Address2_c    ="";
string Address3_c    ="";
string City_c      ="";
string State_c      ="";
string PostalCode_c    ="";
string Country_c    ="";
string ContactPerson_c  ="";
string ContactPhone_c  ="";
string ContactEmail_c  ="";
string ShipVia_c    ="";
bool orderhedconfirmed = false;
bool orderrelconfirmed = false;
int orderrelnum = 0;
int orderlinenum = 0;


if(ttJobOper.Any())
{

this.PublishInfoMessage(msg,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
      foreach (var joboperrow in (from joboper_Row in ttJobOper
                                    //where  joboper_Row.Company == company && joboper_Row.OrderNum == ordernum
                                    select joboper_Row))
                                    {
                              
                                          //valueOTSCountryNum = countryrow.Description;
                                          jobnum          = joboperrow.JobNum       ;
                                          company         = joboperrow.Company      ;
                                          
                                          this.PublishInfoMessage("checkpoint01",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
                                          int jobnumlength = jobnum.Length;
                                          this.PublishInfoMessage("checkpoint02",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
                                          int orderlineindex = jobnum.IndexOf('-')+1;
                                          this.PublishInfoMessage("checkpoint03",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
                                          int orderrelindex  = jobnum.IndexOf('-', jobnum.IndexOf('-') + 1)+1;
                                          
                                          this.PublishInfoMessage(jobnum,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
                                          this.PublishInfoMessage(jobnumlength.ToString(),Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
                                          this.PublishInfoMessage(orderlineindex.ToString(),Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
                                          this.PublishInfoMessage(orderrelindex.ToString(),Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
                                          
                                          string orderlineindexstring = jobnum.Substring(orderlineindex, orderlineindex-orderrelindex-2);
                                          string orderrelindexstring  = jobnum.Substring(orderrelindex, jobnumlength-1);
                                          
                                          this.PublishInfoMessage(orderlineindexstring,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
                                          this.PublishInfoMessage(orderrelindexstring,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
                                          
                                          string callcontext = callContextBpmData.Character01;
                                          string rowmod = joboperrow.RowMod;
                                          if(!rowmod.Equals("U") || !callcontext.Equals("UPDATE ORDER"))
                                          {
                                          }
                                          else
                                          {
                                                foreach (var jobprodrow in (from jobprod_Row in Db.JobProd
                                                      where  jobprod_Row.Company == company && jobprod_Row.JobNum == jobnum
                                                      select jobprod_Row))
                                                      {
                                                      ordernum          = jobprodrow.OrderNum       ;
                                                      }
                                          
                                          
                                          
                                                foreach (var orderhedrow in (from orderhed_Row in Db.OrderHed
                                                      where  orderhed_Row.Company == company && orderhed_Row.OrderNum == ordernum
                                                      select orderhed_Row))
                                                      {
                                                            foreach (var orderrelrow in (from orderrel_Row in Db.OrderRel
                                                                  where  orderrel_Row.Company == company && orderrel_Row.OrderNum == ordernum && orderrel_Row.OrderLine == orderlinenum && orderrel_Row.OrderRelNum == orderrelnum
                                                                  select orderrel_Row))
                                                                  {
                                                                        ordernum          = orderrelrow.OrderNum       ;            
                                                                  }
                                                            
                                                            //CustName_c      = orderhedrow.UDField<System.Boolean>("CustName_c");
                                                            if(true)
                                                            {
                                                            
                                                            
                                                            }
                                                            
                                                            CustName_c      = orderhedrow.UDField<System.String>("CustName_c");
                                                            Address1_c      = orderhedrow.UDField<System.String>("Address1_c");
                                                            Address2_c      = orderhedrow.UDField<System.String>("Address2_c");
                                                            Address3_c      = orderhedrow.UDField<System.String>("Address3_c");
                                                            City_c        = orderhedrow.UDField<System.String>("City_c");
                                                            State_c        = orderhedrow.UDField<System.String>("State_c");
                                                            PostalCode_c    = orderhedrow.UDField<System.String>("PostalCode_c");
                                                            Country_c      = orderhedrow.UDField<System.String>("Country_c");
                                                            ContactPerson_c    = orderhedrow.UDField<System.String>("ContactPerson_c");
                                                            ContactPhone_c    = orderhedrow.UDField<System.String>("ContactPhone_c");
                                                            ContactEmail_c    = orderhedrow.UDField<System.String>("ContactEmail_c");
                                                            ShipVia_c      = orderhedrow.UDField<System.String>("ShipVia_c");
                                                      }
                                                callContextBpmData.Character01 = "";                                      
                                          
                                          }
      
                                    }

}

Hi @Banderson
Would you be able to refer me to a working example?
Many thanks :slight_smile:

Hi @dr_dan ,

I just went through my BPM code as you suggested and indeed there was an issue. I was using the Substring method and it was out of bounds.
I am shocked though, it seems unlike a Debugging process in an IDE like Visual Studio, Epicor debugs the whole code and if it fails, does not show the stack trace in order until it fails.
I also verified that only the JobOper record that is selected is being impacted.

So it seems everything is working, I learned something new today. I have to check the result tonight after fully writing the code.
Thank you @dr_dan !

1 Like

Glad you got it working!

1 Like