BPM Code in UBAQ Works in Pilot, not in Live

Hello everyone. We’re hoping were missing something small. We created a UBAQ that grabs all employees that are clocked into a job. We stuck a BPM in the GetList list method right in the BAQ itself. All the BPM does is set LaborDtl.EndActivity to true (clocks the user out) and saves.

This thing works beautifully in Pilot, but not in Live. Both Pilot and Live are the same versions, are Epicor Cloud Hosted. Why would this thing work in Pilot but not in Live… as far as we can tell, everything is identical.

We need more context. What does the code actually do (show us)

What do you mean it works vs it doesn’t? Any errors?

Thanks Mr. Gomez:

string company = Session.CompanyID;
var empBasic = ServiceRenderer.GetService<Erp.Contracts.EmpBasicSvcContract>(Db);
var labor = ServiceRenderer.GetService<Erp.Contracts.LaborSvcContract>(Db);

var laborHeds = Db.LaborHed.Where(lh => lh.Company == company
                                     && lh.ActiveTrans);
List<string> empIds = new List<string>();

foreach(var laborHed in laborHeds) {
  Erp.Tablesets.LaborTableset laborTs = labor.GetByID(laborHed.LaborHedSeq);
  
  int updates = 0;
  
  foreach(var laborDtl in laborTs.LaborDtl.Where(ld => ld.ActiveTrans)) {
    laborDtl.EndActivity = true;
    laborDtl.RowMod = "U";
    updates++;
  }
  if (updates > 0) {
    labor.Update(ref laborTs);
  }
  empIds.Add(laborHed.EmployeeNum);
}
foreach(string empId in empIds) {
  string e = empId;
  empBasic.ClockOut(ref e);
}

After the code executes, it sends an email telling us who was clocked in (and thereby clocked out). In Pilot, no error, email sent, list on email was correct, employees actually clocked out. In Live, no error, email sent, list on email was correct, employees not clocked out.

Probably would have been more efficient to schedule a function, but this should work, especially considering it works great in Pilot.

Any insight would be great. Perhaps back to the drawing board…

Try using a transaction scope? if the email was correct the data should have been too. Unless it is failing in the actual save / execution

It may be also silently failing try using a try catch.

2 Likes

This is going to sound basic - but were you able to go to that employee record and clock out? Would it let you?

3 Likes

I have something similar set up, and every once in a blue moon, there will be a mismatch between a header record and a dtl with the activetrans.

They error then. Never been able to track down the cause.

I do it one record at a time for error catching reasons.

2 Likes

Thanks fellas! You’re all right. I need to isolate more. I will do that, and report back. Also, Jose I will use txscope/trycatch and see what happens.

Back at it :sunglasses:

3 Likes

Thanks everyone for your input and help! Isolation worked in this instance. Found out it was the scheduling of the UBAQ that was failing. UBAQ itself was fine. Kinda feel silly for posting this now, honestly. If anyone else hits a similar issue, make sure to run things manually first and then work on leaving it up to the scheduler :slight_smile:

2 Likes