5 Replies Latest reply on Apr 2, 2012 1:15 PM by bumper

    Exporting only modified records

    mplent

      I am new to scripting. Does anyone have a simple script to export only records that have been modified I can mess around with?

        • 1. Re: Exporting only modified records
          taylorsharpe

          You will first have to create a field that has a Timestamp of the last modified date/time for each record.  That way you can run a script that will search for any changes that have occurred since a specific date/time, which is probably the last time you ran the script.  You could store this date/time in another table so you know each time you run this script and can only search for records greater than the last date/time recorded.  The script is something you need to do after adding the modified date/time timestamp field as well as create another table to record when you last ran the script.  Just keep in mind that a script can only do what you can normally get around in FileMaker and do manually.  Knowing how to walk through the process manually is the first step to writing a script.  Probably someone will write you one as an example here, but I am not at a machine with FileMaker on it now.  However, if someone hasn't done it in the next day or two, I can do it for you. 

          1 of 1 people found this helpful
          • 2. Re: Exporting only modified records
            mplent

            Thank you for the reply.  I really appreciate the input!  Yes, I have already created the timestamp field.

             

            Field Name: Date_ Modified   Type:Date    Options: Indexed, Modifcation Date

             

            All of my previous scripting has been in dbase/foxpro.   I am just unfamiliar with how its done in filemaker.

             

            I am looking to export only modified records to a .csv file so it can be uploaded to another database to record changes/modifications.  The other database is not filemaker.

             

            I figured I would create a button to trigger the script.  Kicking the file out as an email attachement to a given email address would be my ultimate goal.

             

            I am just looking for something to get me started that I can learn the scripting launguange on.

             

            Any few lines you can kick out to me would greatly appreciated. 

             

            Thank you,

            Matt

            • 3. Re: Exporting only modified records
              gcatnine

              Doing this with ModificaionTimestamp is quite complex.

              Modificaion timestamp change continuously, as a matter of fact, when you create a new record, it store the time when you save the record, so it is always different from the Creation Timestamp.

              I would rather use a boolean field and modify its status  when a record is modified.

              Probably it works too creating a script to do that and assigning it to a layout script  trigger “On Commit Record”

               

              So, all you need is t:

              assign 0 to this filed when you create a new recotd

              use the script to modify it to 1 when you change the record

              find all records with boolean field = 1 (f.i.) and export them

               

              Gcatnine

              • 4. Re: Exporting only modified records
                LyndsayHowarth

                Agreed!

                 

                I have this kind of flagging for export to an account's package. I do use dates which are populated after the export has taken place... so my searching for what to export is just to look for for date is empty.

                 

                This is obviously no good if the same records will be re-exported but is good if you export only once. If there are any errors, it is therefore easy to trace which date's exports need re-doing.

                 

                - Lyndsay

                • 5. Re: Exporting only modified records
                  bumper

                  The set flag works as long as you remember to reset all records to "0" after the export.

                   

                  Kevin Frank's website FileMakerhacks has a demo file that uses a timestamp that only changes when the data is changed. The nice thing about the selective timestamp is that you only set it up once because it's field based and there are no scripts or triggers to set. With the flag you have to set up every layout that you need to track.

                   

                  However all of these fail on false positives, for instance when a user makes a data change in error and corrects it back or even puts a space in error and removes it.