June 20, 201213 yr Is there a way to validate a calendar pick... wherein the enduser gets a message if the date picked is not a Saturday?
June 20, 201213 yr Try the following script as OnObjectExit trigger: If [ DayOfWeek ( myTable::myDateField ) <> 7 ] Show Custom Dialog [ Please choose a date that is a Saturday.” , button “OK” ] Go to Field ( Select/perform; myTable::myDateField ] Halt Script End If This will keep the user in the field until they pick a Saturday date. If this merely intended as a message, remove the Go to Field (optionally) and Halt Script steps.
June 20, 201213 yr Is there a way to validate a calendar pick... You colud use this calculation for the validation option of that field: DayOfWeek ( Self ) = 7
June 20, 201213 yr Author Try the following script as OnObjectExit trigger: If [ DayOfWeek ( myTable::myDateField ) <> 7 ] Show Custom Dialog [ Please choose a date that is a Saturday.” , button “OK” ] Go to Field ( Select/perform; myTable::myDateField ] Halt Script End If This will keep the user in the field until they pick a Saturday date. If this merely intended as a message, remove the Go to Field (optionally) and Halt Script steps. This will work perfectly, thank you both for your help... mp
June 20, 201213 yr Author I'm doing something wrong. When I went to create the script I entered the folloiwng: If [ DayOfWeek ( _TIMECARD::WeekendingDate) <> 7 ] Show Custom Dialog [ Please choose a date that is a Saturday.” , button “OK” ] Go to Field ( Select/perform; _TIMECARD::WeekendingDate ] Halt Script End If When I go to save the script it highlights the If portion of the script and returns the message: "The specified table cannot be found". The name of my table is _TIMECARD so I'm confused why Iwould get this message. Any ideas?
June 20, 201213 yr When I go to save the script it highlights the If portion of the script and returns the message: "The specified table cannot be found". The name of my table is _TIMECARD so I'm confused why Iwould get this message. Any ideas? What does it read in the bar next to “Table:” when you switch to Layout mode? Not the table name is relevant, but the name of the TO the layout is based on. You can also switch to Layout mode, open the Layout Setup dialog and see the TO name next to the popup “Show Records from:”. (This is another example of FMI confusing people by inconsistently mixing “Table” and “Table Occurrence“ within the UI!) EDIT: Forget all that. What you did was probably copying my example text 1-to-1 into the Specify box for the Custom Dialog. FileMaker complains about a syntax error because there are not enough quotes. Write this text incl. quotes: "Please choose a date that is a Saturday.” Put the “OK” into the box labeled ”Default button”. This should work now. Forget the first two paragraphs.
June 20, 201213 yr Note that: 1. The If clause should end with Exit Script [False], rather than Halt Script - there may be other scripts running. If this is triggered OnObjectExit, the attempt to exit will be aborted, so the script can be shortened to: If [ DayOfWeek ( YourTable::Datefield ) ≠ 7 ] Show Custom Dialog [ ... ] Exit Script [ False ] End If 2. Running the script is no substitute to validating at data level.
June 20, 201213 yr Author EDIT: Forget all that. What you did was probably copying my example text 1-to-1 into the Specify box for the Custom Dialog. FileMaker complains about a syntax error because there are not enough quotes. Write this text incl. quotes: "Please choose a date that is a Saturday.” Put the “OK” into the box labeled ”Default button”. This should work now. Forget the first two paragraphs. That works BEAUTIFULLY! Many thanks once again... mp :laugh2:
Create an account or sign in to comment