3 Replies Latest reply on Aug 27, 2013 9:21 AM by philmodjunk

    Auto Create a record of Dates on daily basis.

    ShaikhAtta

      Title

      Auto Create a record of Dates on daily basis.

      Post

           Hello , I want to create a table which would have a single field titled as "Date" in this table there will be only dates from 01/01/2013 to date, and every day it should create an upcoming date of the next day. 

            

           I know there will have to be a OnTimer script used but what will be the rest of the script where it will create the next date. for example if I manually fill in the first record field with 01/01/2013 then how will the rest of the dates be created. 

            

           Thanks in advance. 

        • 1. Re: Auto Create a record of Dates on daily basis.
          philmodjunk

               I would not use InstallOnTimerScript for this. If hosted from FileMaker Server, you can use a server scheduled script that adds one such record every day.

               If you do not host the file with server, I'd use file options to set a script to run each time the file is opened. The script can check to see if a record with today's date exists and create one if one is not found. This script can also be set to create previous days as well as today's to "catch up" in cases where the file has not been opened for a day or more. (And this is not a bad approach for a server scheduled script either as there are circumstances that might keep a schedule from performing a script on a given day.)

          • 2. Re: Auto Create a record of Dates on daily basis.
            ShaikhAtta

                 Thank alot Phil, 

                                            What sort of script do I have to write so the dates are created upon file open, can you please tell.

                  

                 Thanks

            • 3. Re: Auto Create a record of Dates on daily basis.
              philmodjunk

                   Freeze Window
                   Go to Layout [DatesTableLayout]
                   Enter FInd mode [] --> clear the pause check box
                   Set FIeld [YourDatesTable::Date ; Get ( currentDate ) ]
                   Set error capture [on]
                   Perform Find []
                   IF [Not Get ( FoundCOunt ) // no record with today's date was found ]
                      Show All Records
                      Sort Records [Restore ; no dialog ] ---> sort by date in ascending order
                      Go to Record/Request/Page [Last ]
                      Set Variable [$Date ; value: YourDatesTable::Date ]---> set variable to date of most recent date in table
                      Loop
                          Set Variable [$Date ; Value: $Date + 1 ]
                          Exit Loop if [ $Date > Get ( CurrentDate ) ]
                          New Record/Request
                          Set Field [ YourDatesTable::Date ; $Date ]
                      End Loop
                   End If
                   Go to Layout [//specify the layout you want the user to see when they first open the file here ]

                   A robot file can also be scheduled to be opened and run this script once a day via an OS based task scheduling utility if you don't want this to run every time the file is opened.