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.
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.
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.
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
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.
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.
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?
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.