Forum Discussion

AndrewNelson's avatar
AndrewNelson
Qrew Cadet
6 years ago

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? 

2 Replies

  • You are correct that the Summary values are not calculated until after the record is Saved so the form Rules will never fire.

    The suggestion I have though is to send an instant email notification to the user who just created the parent record to let them know they made a mistake. That way they can correct their mistake before payroll has a chance to review it. Generally, users are trying not to make mistakes and if given an opportunity they will correct them. You can also place a big red warning message on the record itself so that when the user saves the record not only will they receive an instant email beep but they will also see a big red error message.
  • UrsulaLlaveria's avatar
    UrsulaLlaveria
    Qrew Assistant Captain
    I am running across a similar issue currently. We need to have the items in our embedded grid edit report be populated before they save the parent record. The problem we are having is that they are saving the parent without adding or updating the records on the grid edit report. We tried a Custom Data Rule, but those don't always work. Did you end up finding a way to make it work?

    ------------------------------
    Ursula
    ------------------------------