Update Labor Detail using UBAQ Labor Hours Don't Recalc

I’m trying to make a UBAQ that allows my production supervisor to update labor detail records from the dashboard. I traced the Time and Expense activity and attempted to replicate the method calls in the UBAQ. It appears to be working 90% of the way there.

I can’t get the Labor Hours and Burden hours to recalculate when I change the clock in/out time like the system will do if you manipulate those within Time and Expense. Anyone know any tricks? I could just do the math however, I am trying to let the system do it because there are times when we have one person with multiple active detail records and I want the system to calculate the “split time” and also to calculate the break times and such.

Are you calling LaborDtl.Update? That should handle everything…

Yes. But you made me think… maybe because I’m doing a UBAQ and it calls an UpdateExt that it’s fighting itself. I’m going to switch it to Advanced BPM only and see what that does for me.

Well, I tried the Advanced BPM Only and that doesn’t seem to do anything. It Updates and makes it look like you’d expect it would look in the BAQ, but then it doesn’t actually save the record in Time and Expense. No errors. Just doesn’t work.

This is what I’m running with if anyone is familiar… maybe something looks off?

foreach (var eachRow in (from q in queryResultDataset.Results
                        where q.Calculated_Update = true
                        select q))
  Erp.Contracts.LaborSvcContract boLabor = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.LaborSvcContract>(Db);
  Erp.Tablesets.LaborTableset dsLabor = new Erp.Tablesets.LaborTableset();  
  dsLabor = boLabor.GetByID(eachRow.LaborHed_LaborHedSeq);
  var laborDtl = (from ld in dsLabor.LaborDtl
                  where ld.LaborDtlSeq == eachRow.LaborDtl_LaborDtlSeq
                  select ld).FirstOrDefault();
  if (laborDtl != null)
    string cMessage = "";
    boLabor.RecallFromApproval(ref dsLabor, false, out cMessage);
    decimal clockInTime = 0;
    decimal clockOutTime = 0;
    boLabor.GetClockTime(eachRow.LaborDtl_DspClockInTime, out clockInTime);
    boLabor.GetClockTime(eachRow.LaborDtl_DspClockOutTime, out clockOutTime);
    eachRow.LaborDtl_ClockinTime = clockInTime;
    eachRow.LaborDtl_ClockOutTime = clockOutTime;
    laborDtl.ClockinTime = clockInTime;
    laborDtl.ClockOutTime = clockOutTime;
    laborDtl.RowMod = "U";
    boLabor.DefaultDtlTime(ref dsLabor);
    string vMessage = "";
    boLabor.CheckWarnings(ref dsLabor, out vMessage);
    boLabor.Update(ref dsLabor);

I can’t seem to find the method that will recalculate the labor/burden hours. It appears based on my trace that it’s the DefaultDtlTime that is doing it… but as you can see above, I’m firing that method and it’s not doing the recalc.

Are you recalling then approving when finished?

I am not approving yet within the BPM… but I plan to. I thought it would be fine if I didn’t approve similar to how I can edit in Time and Expense and save it without Approving.

I’m assuming you are walking through a trace? I notice that there is a Labor DLL and a LaborDtl DLL. It’s not using 2 different ones is it? (I wouldn’t expect it to, but I was curious)

But, looking through the methods on Labor, I see one for ChangeLaborDtlDspTimeField(). It seems like that one might be what you’re looking for? I didn’t test anything, I was just looking for the usual suspects “OnChange…” methods, and this what I found.

1 Like

Yes, I ran a trace and was following it. I am using the Labor dll, not the LaborDtl. I didn’t consider there might be something to check, though.

I found that method too and it didn’t appear to work when I tried it in the BPM - but I’ll try to figure out how to use the BL Tester to maybe get a better understanding of it. It was not called in the trace but I did see it in there.

It is possible that the calculation is just done client side (there are some places where they do that, and it’s annoying), in which case, you’ll just have to do it yourself.

1 Like

Thanks. I’ll try it and see. My main reservation was that I just don’t know what that calculation is nor how to check. I am aware that it takes into account multiple concurrent labor details (not sure if there is any way to weigh the splitting or if it’s just an even split) and it also takes into account break times. Knowing just that, I can hazard a guess.

The split looks something like this.
Job-1 Clock in 1:00
From 1:00 - 1:15 Full allocation 15 minutes
From 1:15 - 1:30 Split between 2 jobs 7.5 minutes
From 1:30 -1:45 Split between 3 jobs 5 min
From 1:45 - 2:00 Split between 2 jobs 7.5 minutes
35 min total allocated to job-1


I got it figured out. It had to do with the fact that it’s a UBAQ and when I run the “Update”, the row I am trying to modify gets marked with a RowMod = “U” and I was not accounting for that. So I was getting two rows when I thought I’d get one… Somehow it wasn’t working yet it would not error. At the end of the day, I have it working now. The logic from the trace works. It had to do with my silly UBAQ custom code. That’s ultimately how I found it. I started converting it to BO widgets and checking everything one step at a time… because in the UBAQ I am trying to make it handle conceivably several updated rows at a time. But yeah, we got it working. Thanks everyone.

1 Like