AndrewNelson
7 years agoQrew Cadet
When the record is saved"" form rules trigger before embedded grid edits
We have an app that allows users to submit timesheets every week. The table structure is pretty simple: there is a Timesheets table that stores the timesheet itself, and then a child table of TimeEntries, which hold the individual lines on the timesheet. So, for example, a foreman could create a timesheet that contains TimeEntry lines for each member of his crew (for a single day's work), or a back office employee can create a timesheet that contains TimeEntry lines for each day worked (for a single employee). The TimeEntries are added from the Timesheet submission form with an embedded grid edit.
Here's my problem: I want to set up a form rule that checks to make sure that the dates on each TimeEntry line fall within the acceptable range based on the date on the parent Timesheet. If there is a date that falls out of bounds, the rule is supposed to abort the save and display a message to the user. I set up all of the summary fields in the relationship to determine the maximum and minimum dates on the TimeEntries, and compare those to the expected max/min on the Timesheet (determined with some formula fields). The rule is all set up the way it should be, the logic checks out and it should be working, but... it doesn't trigger.
What it sounds like to me is that the summary fields for the relationship don't populate until after the record is saved, or perhaps that the child records save AFTER the parent record (which I suppose makes sense - the children need to have the RecordID from the parent in order to save that info). I've considered forcing the user to save the parent record first, before entering the child records, but then we run into permission issues since most users have permission to submit timesheets but not edit them. The alternative (what we're doing now), is to use the same logic to detect these discrepancies after the fact, which works, but then the changes need to be made by payroll manually, and it doesn't have the instant feedback to employees that are making the mistakes in the first place.
So the question is, how can I achieve this? Is there any way to compare the child records to the parents before the record saves if all of the records are being created at the same time?
Here's my problem: I want to set up a form rule that checks to make sure that the dates on each TimeEntry line fall within the acceptable range based on the date on the parent Timesheet. If there is a date that falls out of bounds, the rule is supposed to abort the save and display a message to the user. I set up all of the summary fields in the relationship to determine the maximum and minimum dates on the TimeEntries, and compare those to the expected max/min on the Timesheet (determined with some formula fields). The rule is all set up the way it should be, the logic checks out and it should be working, but... it doesn't trigger.
What it sounds like to me is that the summary fields for the relationship don't populate until after the record is saved, or perhaps that the child records save AFTER the parent record (which I suppose makes sense - the children need to have the RecordID from the parent in order to save that info). I've considered forcing the user to save the parent record first, before entering the child records, but then we run into permission issues since most users have permission to submit timesheets but not edit them. The alternative (what we're doing now), is to use the same logic to detect these discrepancies after the fact, which works, but then the changes need to be made by payroll manually, and it doesn't have the instant feedback to employees that are making the mistakes in the first place.
So the question is, how can I achieve this? Is there any way to compare the child records to the parents before the record saves if all of the records are being created at the same time?