# Time and Expense Reporting BPM **Category:** [Epicor ERP 9](https://www.epiusers.help/c/e9/7) **Created:** 2016-12-07 15:18 UTC **Views:** 2954 **Replies:** 23 **URL:** https://www.epiusers.help/t/time-and-expense-reporting-bpm/36536 --- ## Post #1 by @Verholdt Hello, I'm trying to set up a BPM for Time and Expense such that when an employee enters time, a check is made against labored.payhours to ensure they're not entering more time than is appropriate. I've tried methods on Labor.Update pre and base processing to check those and if pay is less than labor, create an error message and it won't do it. Any suggestions would be welcome, thanks! Zach --- ## Post #2 by @Aaron_Moreng Have you made sure that you're running your check on the pre-processing record against the added row in the temp table? --- ## Post #3 by @Verholdt Thank you for the reply Aaron, Which added row – it’s not until right at the end of update from what I can see that laborhed.totlbrhrs is updated. I can create a sheet rule to turn the box red but I can’t get the BPM to trigger at the right time. I’ve tried the added row in laborhed, and using labordtl to trigger it. Any ideas? --- ## Post #4 by @Aaron_Moreng There should be an incoming value for the laborhed.payhours that is attempting to be submitted to the Labor.Update method. I could be wrong, but the total hours is likely calculated after the method successfully completes, because it's adding in what was passed into the method against what was already in the table. Try this: using a custom code block, get the value of the added row for the pay hours. Then, do a lookup against the Labor table and get the current Total Hours value. Perform the calculation of what it would potentially be if the method submitted without problems. If the value is what you expect, do nothing. If the value is greater than the time you want to allow, throw an exception. This will prevent the method from actually updating the database and will force your user to enter the correct info. It also sounds like you've tried this using a form customization. I'd stick to the BPM approach first, then if you need a form customization to help enforce, you can always have it do a lookup on an event. --- ## Post #5 by @Verholdt This is great – one question, what would constitute a custom code block? Are you suggesting ABL code in the Method Directive? --- ## Post #6 by @Aaron_Moreng Yes, and I totally forgot you are in E9 and not E10, so I won't be able to help very much with the ABL :slight_smile: I bet we could fight our way though it though, it can't be that difficult. Make sure you build it on the pre-processing method directive and not the base. --- ## Post #7 by @Verholdt Awesome, thank you. I will give it a try and advise on how it goes. I understand 10 would be easier, we’re just not there yet. Thanks for all your help. Zach --- ## Post #8 by @gpayne Attached is the ABL I use to stop over reporting of production quantities pre-processing on Labor.Update. You should be able to adapt it from quantities to hours. Greg --- ## Post #10 by @Verholdt Thank you Greg but I don't see the code? How do I retrieve an attachment or could you paste it here for me? Thank you so much, Zach --- ## Post #11 by @gpayne I changed the extension from .p to .txt If this doesn’t come thru then send me your email address. MODS: can we send .p extensions? Greg Stop Over Reporting of labor Qty V2.txt (2.33 KB) --- ## Post #12 by @Verholdt This is excellent Greg, I'm impressed and the .txt works fine. One further question, what's the significance of the numbers at the start? 9906? Is that specific to your op set? I'm new to ABL and am more of an updatable dashboard creator. Thanks Zach --- ## Post #13 by @gpayne Yes, the customers and 9906 are specific to us. I just sent you the whole thing since I knew it would compile. I got the main parts of this from the previous Yahoo group, so it not totally a creation of mine. --- ## Post #14 by @rbucek you can now :slight_smile: --- ## Post #15 by @gpayne Thanks Rob --- ## Post #16 by @Verholdt Hello Greg, I’d created a pre-processing method directive and included the code. It will not trigger for me. I’m trying to us a labordtl.submittedby changed from any to any and it won’t trip the check. How do you trigger yours and at what time? Thanks, Zach --- ## Post #17 by @Aaron_Moreng Make your row mod "A" and try that --- ## Post #18 by @Verholdt I’ve tried that – and E, and S in case it was sticking there. It won’t trigger. Any other ideas? Do I have to import the method into a customization? I thought it should just activate when the condition is met. --- ## Post #19 by @Aaron_Moreng BPMs are independent of form customization as they act server side rather than client side. Since this is the Update method, it will require you to "save" the transaction before it will fire. Have you performed a trace log of the transaction you are building on to make sure you're targeting the correct method? --- ## Post #20 by @Verholdt Yes, I’ve run the trace. It won’t be saved, it’s just submission and that may be the issue. Would it make more sense to trigger it on a change to say labordtl? --- ## Post #21 by @Aaron_Moreng I believe you are on the right method, because as soon as the user tries to save, it will perform this calculation. If the calculation fails your criteria (as specified in the code) and the BPM throws an exception, the method will not actually complete and save data to the database. --- ## Post #22 by @Verholdt Right, everything I’m doing with it, it’s just not calling the error and moves right to saving the data. I will try stripping out the move request part and see if that is where it’s stuck. --- ## Post #23 by @Verholdt That did it – removing the enablemoverequest portion of the coding – we don’t use move requests. I imagine the system was looking at those and skipping over the action. Thanks for the assistance. If I can get it to work for hours as well I’ll post it too. --- ## Post #24 by @Aaron_Moreng Glad it worked! --- ## Post #25 by @gpayne Sorry, stuck in meetings all day. I don’t use any conditions on the bpm. The message lines get written into the appserver log. I use those to know what is happening behind the scenes. If you add one at the top of the bpm before the code you will know that the bpm was at least loaded. You will need a log viewer to have the log open while the appserver is using it. I use LTViewer If you want to paste your code I can try to run it. --- **Canonical:** https://www.epiusers.help/t/time-and-expense-reporting-bpm/36536 **Original content:** https://www.epiusers.help/t/time-and-expense-reporting-bpm/36536