6 Replies Latest reply on Nov 19, 2015 5:29 AM by wimdecorte

    FM 14.04 adv backup and remove 'inactive' records.

    synergy46

      What is the best 'method' to do this?  (via script)

       

      I have a membership application.  It has 'active' or 'inactive' member status stored in the STATUS field.

       

      I  want to write a script that will:

      backup (save as...?) the MEMBER &  associated DUES, AWARDS etc.... tables to a user defined file and then delete the backed-up records in the main Membership app.    The expectation is that the user can 'import' these records back into the main app later.

       

      From  what I see, using Save As copies everything.... (active and inactive).  Is there a way to use save as to copy just the 'found set' of 'inactive records'?

       

      Thanks

       

      R

        • 1. Re: FM 14.04 adv backup and remove 'inactive' records.
          mikebeargie

          You just need the export records. Save As copies the entire database (layouts, scripts, etc..), that's good for backups and such, but not necessarily for record storage. You can use the export records script step to save a .fmp12 file that is pretty much the best data-only backup format you should need.

           

          A script would look something like:

           

          Perform Find [ specify requests ; table::status = "inactive" ]

          if [ get(foundcount) > 0 ]

             Export Records [ file.fmp12 ; all fields in current table ]

          End If

           

          One note when reimporting records, make sure to uncheck the "perform auto enter fields" in the import dialog, or else you could run into key matching issues and such.

           

          Or an even better idea, just leave the records in there and add layout triggers to automatically constrain the found set to omit any inactive records. This way you don't run the danger of losing track of any data in exported backups.

          • 2. Re: FM 14.04 adv backup and remove 'inactive' records.
            synergy46

            Doesn't Export Records just move the records in the current table ?

             

            For example, my Main window has the main layout called Members.  On it, there are several portal based tables:  Awards, Dues, Etc. 

             

            Don't I have to Export from each of the 'many' related tables to it's own table?

             

            BTW, I really like the Portal Filter idea.  But, I have all ready implemented it and users are finding that such filtering does not render the app faster than when it is NOT implemented.  Hence the need to export.

             

            Thanks

             

            R

            • 3. Re: FM 14.04 adv backup and remove 'inactive' records.
              mikebeargie

              Yes, but you can still script via Go To Related Records and export the child tables as well.

               

              There are ways to optimize portal filtering (EG making the filter relationship based rather than calculation based, caching data, etc..) Talking to a skilled mentor may prove useful and give you some alternative ideas.

               

              As I noted, as soon as the data is out of the file, it becomes a liability. If that's the best solution for your client and they understand the repercussions, fine. More times than not, having to track down a file that was removed months or years ago from the main file has haunted many a developer.

              • 4. Re: FM 14.04 adv backup and remove 'inactive' records.
                synergy46

                Users currently have the ability to SAVE AS .... a backup copy of the app.

                 

                Assuming I have a backup copy on my desktop called backup.fmpur and an active, working copy called Membership.fmpur, I need to run a script stored in Membership.fmpur that will access (open?) backup.fmpur, delete all the 'Active' records and then import the remaining 'Inactive' records.

                 

                I got the importing to work but can't figure out how 'go to / open' the backup.fmpur file to delete the Active records.

                 

                Ideas?

                 

                Thanks

                 

                Ron

                • 5. Re: FM 14.04 adv backup and remove 'inactive' records.
                  mikebeargie

                  Sorry, I don't really work with runtimes at all. Usually your files have to be allocated to the runtime bundle for them to be accessible, so you're probably losing context when you export.

                  • 6. Re: FM 14.04 adv backup and remove 'inactive' records.
                    wimdecorte

                    synergy46 wrote:

                     

                    I got the importing to work but can't figure out how 'go to / open' the backup.fmpur file to delete the Active records.

                     

                     

                    You can't.  The only way to work with data from another file is have a file reference to that other file, which can not be done dynamically.

                     

                    You will have to bite the bullet and script an exporting routine that exports the data and all of the related data.