BPM to popup message upon MES clockin based on clockin time

I’ve written a BPM on LaborHed.Update when a LaborHed record has been added which, upon ClockIn, compares the ClockIn time to the Shift ClockIn time. I popup a message if they are late within 15 minutes, late between 15 and 30 min, late between 30 and 45 min, and another if greater than 45. Works great in Time and Expense entry but I get nothing at all in MES even though a LaborHed record has been created. A trace in MES really tells me nothing at all.

Any help would be appreciated.
Thanks,
Chris

Can you post images of your BPM?

Sure. Images or my code?

    /* Detect late clockin. Message about deduction */

var TimeVariance = decimal.Zero;
string NowTime = string.Empty;

Erp.Tables.EmpBasic EmpBasic;
Erp.Tables.JCShift JCShift;

foreach (var ttLaborHed_iterator in (from ttLaborHed_Row in ttLaborHed
                                    where ttLaborHed_Row.Company == Session.CompanyID
                                    select ttLaborHed_Row))
{
var ttLaborHed = ttLaborHed_iterator;

  EmpBasic = (from EmpBasic_Row in Db.EmpBasic
                      where EmpBasic_Row.EmpID == ttLaborHed.EmployeeNum && EmpBasic_Row.ShopEmployee_c == true
                      select EmpBasic_Row).FirstOrDefault();
  if (EmpBasic != null)
  {
    NowTime = DateTime.Now.ToString("HH:mm");
    decimal NowTimeDec = Convert.ToDecimal(TimeSpan.Parse(NowTime).TotalHours);
    ttLaborHed.ActualClockInTime = NowTimeDec;
    
      JCShift = (from JCShift_Row in Db.JCShift
                where JCShift_Row.Shift == ttLaborHed.Shift
                select JCShift_Row).FirstOrDefault();

      if (JCShift != null)
      {
        if (NowTimeDec > JCShift.StartTime)
        {
          TimeVariance = NowTimeDec - JCShift.StartTime;
          if (TimeVariance <= Convert.ToDecimal(.25))
            {
              this.PublishInfoMessage("Docked 15 min!",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
            }
          if (TimeVariance > Convert.ToDecimal(.25) && TimeVariance <= Convert.ToDecimal(.5))
            {
              this.PublishInfoMessage("Docked 30 min!",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");            
            }
          if (TimeVariance > Convert.ToDecimal(.5) && TimeVariance <= Convert.ToDecimal(.75))
            {
              this.PublishInfoMessage("Docked 45 min!",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");            
            }
          if (TimeVariance > Convert.ToDecimal(.75))
            {
              this.PublishInfoMessage("Might as well have stayed home!",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");            
            }
        }
      }
  }
}
1 Like

Both would be good! I’m on a different version than you, but it doesn’t look like an Update method is being called in my stack trace when I clock in via MES. Do you see it in your MES trace?

No I don’t see one either. Like I said, the trace in MES doesn’t really tell me much. I found one single search results which mentions using EmpBasic and the ClockIn method but it seems no tables are available…

Gotcha, mine says something similar. I was able to get a test message to fire on clockin via a data directive, does your version have data directives?

Were you really? Yes it does. What table did you use?

Gotcha. I did one on the LaborHed table with the same if block condition. I think you should be able to paste everything over and it should hopefully work, and you still have access to the ttLaborHed table.

Wonderful. I will try it shortly and update you. Thank you!

1 Like

Data directive worked great. Kick myself for not trying this first before posting this in the group. lol

Thank you!

1 Like

Good deal, no problem! On the bright side, now your customization is available for all to use/learn from!