EmpBasicService.ClockOut - MES Idle Time Auto-Approved


We use the MES Idle Time feature that sums up time not associated with an activity, and creates an indirect LaborDtl record upon clock-out. We also use require Supervisor approval for all labor records.

When clocking out manually via MES, that Idle Time record is ‘Submitted’ and requires Supervisor approval. This is expected and desired behavior.

I have a task that runs nightly to automatically clock out employees that have not clocked out for the day. I use the BAQ Export Process as the scheduled task, and a Data Directive on Ice.SysTaskParam where ParamCharacter = BAQ Name. I have custom code in the Data Directive that calls the EmpBasicService.ClockOut() method for each clocked-in employee.

When the directive code runs, the MES Idle Time record is automatically ‘Approved’ (by our system agent user). If you open the record in Time & Expense Entry, recall, and re-submit the record, it again goes straight to ‘Approved’ without entering the ‘Submitted’ state. The LaborDtl record seems to be corrupted in some way.

When I call the EmpBasicSvc.ClockOut method via REST (as the system agent user) the record is NOT automatically approved. Again, this is what we want.

Why would this behavior be different only when calling the method via the Data Directive Custom Code?


var employees = Db.EmpBasic.Where(emp => emp.Company == Session.CompanyID && empIDs.Contains(emp.EmpID)).ToList();
var empBasicService = ServiceRenderer.GetService<Erp.Contracts.EmpBasicSvcContract>(Db);
foreach(string empID in empIDs)
  var employee = employees.FirstOrDefault(emp => emp.EmpID == empID);

  var clockOutResult = new object[] { empID,
                              employee?.Name ?? "",
                              employee?.SupervisorID ?? "",
                              "" };

      var e = empID;
      empBasicService.ClockOut(ref e);
  catch(Exception ex)
      clockOutResult[4] = true;
      clockOutResult[5] = ex.Message;

As a test, before the directive kicks in, manually clock one of them out while gathering a client trace. If this leaves the record in the desired state, inspect the trace to see if any other calls are made.

Do they have any active labor details at this point? I built something similar and included some code to check if they had active labor details and ended them prior to calling ClockOut. I wouldn’t expect this result but may be worth investigating.

Hi Adam,
I have inspected the trace and there are no additional calls that need to be made. Also, I’ve called the ClockOut method via REST (which should perform the action same as calling it from the custom code), and it works correctly.

I have code that runs before this point to end any active labor details. I have test the code with and without that piece, to ensure that wasn’t causing a problem. Unfortunately I get the same result either way.

It may be worth a try to run the test logged in as the same user your system task agent runs as, to rule in/out user settings.

Which version are you seeing this in?

There must be a field in LaborDtl to know which user created the record, is it the same(the system user agent) for both the Directive and REST?

Here are some examples of LaborDtl (select fields). There are obvious differences between the one created via the Custom Code and the other methods. Several missing pieces of information.

Epicor Version 10.2.500.20

Method LaborTypePseudo JCDept ResourceGrpID IndirectCode LaborNote ClockInMinute ClockOutMinute TaskSetID TimeStatus CreatedBy CreateDate ChangedBy ChangeDate ActiveTaskID WFGroupID ApprovalRequired
Manual Clock Out (MES) I MFG MES_IDLE MFGN IDLE TIME 35310240 35310336 SuprAppr S andrew.johnson 2020-12-18 andrew.johnson 2020-12-18 SuprAppr SuprAppr 1
REST API EmpBasicSvc.ClockOut I MFG MES_IDLE MFGN IDLE TIME 35310240 35310243 SuprAppr S system.agent 2020-12-18 system.agent 2020-12-18 SuprAppr SuprAppr 1

Hi Andrew,

Can you please help me in doing the auto clock out setup through BAQ & Data directives? since some of our employees are forgetting to clock out and it ends up in huge time fixing for the payroll. The autoclock out is the best solution.
It would be great if you can provide me the steps.


Hi @subha,
I used this GingerHelp post as a guide, and customized it for my needs:

Thanks Andrew. Let me check it.