4 Replies Latest reply on Jul 22, 2014 7:37 AM by ChadAdams

    Performing Sort Script on Server

    jprochniak

      Hello all.

       

      I'm currently working on customizing and optimizing the FMP 13 Inventory starter solution for my office. Currently we have approximately 800 aircraft parts in the inventory database and it takes quite some time to perform the "sort" script upon opening the database (it's only going to get worse as I add more items...and it is going to be a lot!). Is it possible to reallocate this script to the server so that it is performed automatically, and in the background, without the user having to endure the five minutes or so it takes their device to perform the sort? In reviewing the following thread I would say no but I'm not sure:

       

      https://fmdev.filemaker.com/message/132022#132022

       

      I'm trying to teach myself FMP, and am not very good at developing scripts, so any help you could provide would be greatly appreciated.

       

      Thanks!

       

      John

        • 1. Re: Performing Sort Script on Server
          ChadAdams

          Hi John,

           

          The most basic answer to your question is No, you can't sort the records on the server, sorting happens at the client.

           

          Some options:

          1. Records are naturally sorted in their creation order.  If you know the sort order and you want it to remain the same for all users, it would be possible to do a server side script that sorted the records as you want them, exported them, deleted them, reimported from the export, so now their creation order is the same as the sort order you want.  All kinds of potential problems here, be careful.
          2. Another option would be to rethink what you are showing the end user.  How useful is it really to have 800 sorted parts records to scroll through?  Perhaps a better solution is to start them with no found set, or the 20-50  most commonly used parts? Going to a big list and scrolling for what you want is still spreadsheet thinking.  Much better to use FileMakers search capabilities to start with fewer (or even zero) records and then let users search for what they want.

           

          Hope that helps,

           

          Chad

          • 2. Re: Performing Sort Script on Server
            ChadAdams

            Another option mght be to:

             

            3. Display the data in a virtual list.  In this case you could utilize the server to gather the data you want, sort it, and push back the IDs you need to produce the virtual list. 

             

            Virtual lists maynot be the right choice here, but you should go learn about them at some point anyway :-)

             

            There are lots of blogs and articles about the virtual list (brain child of Bruce Robertson), just google for FileMaker Virtual List Bruce Robertson and enjoy.

             

            Chad

            • 3. Re: Performing Sort Script on Server
              jprochniak

              Thanks for the assist Chad.

               

              In talking with the guys that will ultimately be using the system, which I should have done a bit earlier, they said that there really is no reason to sort everything at all....they intend to just pop in a part number to search for and really have no intention of searching through our entire parts catalog, which makes sense. You're quite right though, I was spreadsheet thinking. So after all that, I am just going to remove the sort trigger when the database is accessed since there really is no reason for it. I'm definitely going to do some research into the virtual lists though. It sounds like an interesting topic.

               

              On another note, can you, or anyone for that matter, recommend a good resource for learning how to write scripts? The concept makes perfect sense to me, I'm just not well versed in how to formulate them correctly. It's actually quite a daunting thing for me.

               

              Thanks again!

               

              John

              • 4. Re: Performing Sort Script on Server
                ChadAdams

                Hi John,

                 

                Sorry for the delay in replying.

                 

                Scripting is VERY powerful and you can do a TON of stuff.  But it can basically be thought of as a series of instructions that tell the system to complete a particular task. FileMaker scripts are very linear, they basically start at the top and run each step in sequence.

                 

                You can often times think about what you would manually do to complete the task, then go to the scripting engine and see how many steps there are that replicate the maual actions (go to layout, perform find, set field, etc...).

                 

                FileMaker has a great resource for getting you started here.

                 

                Chad