7 Replies Latest reply on Aug 16, 2016 8:18 AM by gdaquino

    Logoff all user before running a script

    gdaquino

      Hello experts!

       

      Is there a way to logout all users connected to a specific database before running a script on server?

       

      I mean, I have to do a lot of updates on a large table and usually that table is in use by some users.

       

      I'll explain it clearly. I have a very big table to be queried (half a million of records) looped for 5000 times.

       

      Basically my head table is the customer table (5000 customer) and the detail table (order lines) must be checked for every customer, calculating the most sold article.

      I run the script on server and it takes few mins to run. But If a user is working on the customer table in that moment the changes won't be written on that specific record, giving me back an error 301.

       

      Considering that the script will be run during the night, is there a way to logoff all users before running the script, so that I'll run on all records?

       

      Thanks and have a great day!

        • 1. Re: Logoff all user before running a script
          coherentkris

          set the users permissions to disconnect when idle in the file and run the process when all users should be off.

          PS google is your friend

           

          https://www.google.com/search?q=filemaker+server+log+off&ie=utf-8&oe=utf-8

          • 2. Re: Logoff all user before running a script
            Mike_Mitchell

            Building on Kris's answer, you should always trap your scripts for errors and deal with record lock (which is what a 301 is) when it occurs. How much of a problem is it if the record isn't updated? Should you set the script up to run more frequently, and set a flag if it's 100% successful? Should you build a list of records that didn't update, and try them again later?

             

            I can't answer those questions for you, but it's prudent to get an answer. Error handling is essential whenever you run automated stuff.

            1 of 1 people found this helpful
            • 3. Re: Logoff all user before running a script
              coherentkris

              As Mike said a transactional approach ala Todd Geist is best when you must have a process run completely or not at all

              1 of 1 people found this helpful
              • 4. Re: Logoff all user before running a script
                gdaquino

                I totally agree with this approach, thanks. I've thought about the fastest and easy way that is to disconnect all user but I think that this is not the right way.

                • 5. Re: Logoff all user before running a script
                  BruceHerbach

                  You could set up a system level script that uses the command line fmsadmin and have it close the database,  then open the database. 

                   

                  Using the FMS scheduler,  you can schedule the system level script and the FileMaker script to run in the correct order.

                   

                  Another thing you can do is have your filemaker script set a field that is checked when the file is opened.    Then have the OnOpen script check this field and if set,  put up a dialog box for the user and then close the file.  So if a late night employee tried to get in while your script is running they won't interfere with your scipt.  Make sure the script clears the field when it is done.

                   

                  Make sure you leave a back door to this so you can get in if something goes wrong.  If you have Pro Advanced opening the file with the debugger open should do it.

                   

                  HTH

                  1 of 1 people found this helpful
                  • 6. Re: Logoff all user before running a script
                    DavidJondreau

                    You're trying to establish the most sold item per customer over all time and then record the results?

                     

                    What about a separate 1:1 table of Customer ID with Product ID to record the result. That will require write privileges on that table only. There should be no conflicts since the server script should be the only user opening those records.

                     

                    You can use some kludgy workarounds to get unattended clients to commit their records (mainly using a persistent off screen window and an OnRecordLoad script trigger), but I don't think that's worth it here.

                    1 of 1 people found this helpful
                    • 7. Re: Logoff all user before running a script
                      gdaquino

                      From a relational point of view is not efficient, btw I think that this workaround would be a solid way in case I have to write those record often during working time.