6 Replies Latest reply on Oct 24, 2016 11:28 AM by mw777rcc

    Sorting issues in layout

    alexchoh

      Hi,

      I am creating a filemaker solution a non profit organization.  I have 400 plus member records.  These members are separated into 4 groups (A,B,C,D).  Each group has 4 sections (A,B,C,D) and each section has 3 to 4 teams (1,2,3,4).  Each team has a number of members in them.

       

      I need the records to be sorted correctly when the account holders connect to my filemaker solution using filemaker go via an iOS device.  The issue is that I can sort them correctly when viewed on my macbook.  But when I connect to my layout remotely using filemaker go, the records are not sorted correctly.  I need the records sorted by the following sequence, group, section then team when the layout is viewed using filemaker go.

       

      Any advice will be greater appreciated.

       

      Thanks!

       

      Alex

        • 1. Re: Sorting issues in layout
          scottworld

          You control sorting through scripts. So simply write a script that sorts your records the way you want them sorted, then trigger the script either manually (e.g. via a button) or automatically (e.g. via a script trigger).

          • 2. Re: Sorting issues in layout
            mw777rcc

            If the data does not change (is static) then you can do the following:

            1) Sort the records

            2) Export the records with all of the data

            3) Import the data again (now sorted)

            4) Delete the original records (toggle the found set (circle like icon at the top) and delete records.

             

            If you need to sort the records every time then edit a navigation script that takes them to that layout to add a sort script step or simply make a single line script that sorts the records like you want and then add it to the onLayoutLoad script trigger for the layout.

            • 3. Re: Sorting issues in layout
              alexchoh

              Hi,

               

              Thanks for your reply.  I have another issue that irritates the hell out of me.

              I have a layout that has a script that forces it into find mode upon entry.

              When I enter a search parameter like last name "Tan".  It searches successfully but it does not sort to my designated field.

              My script for OnLayoutEnter:

              Enter Find Mode [Pause:Off]

              Sort Records [Restore;With dialog:On]

               

              It finds the records successfully but it always shows something like 50 / 400 Found/Unsorted

               

              To solve this, I deleted the sort records line in the script above and added another script trigger for the sorting.

               

              My script for OnRecordLoad:

              Sort Records [Restore;With dialog:On]

               

              Now, the find and sort works but the SAME find always goes to the SAME record.

               

              That means that when I find "Tan", it always goes to the same record (which is record 2 of 50) in all the "Tan" found set.

               

              Please advise.

               

              Thank you

               

              Alex

              • 4. Re: Sorting issues in layout
                mw777rcc

                The issue with your first script is that you are sorting before you do the find.  You enter find mode, sort (which doesn't do anything), and then you enter your find criteria and continue.

                 

                You REALLY do not want to use a sort on an OnRecordLoad script trigger.  Way too much overhead and too many sorts happening all the time.  With a small fund set, you may be able to get away with it but it is very bad practice.   A sort does not change the record number that is active.  This means that the first record in the table (creation order) in your example is happening to be sorted to the second position every time. 

                 

                A better solution to this would be for you to set a sort on two triggers.  OnLayoutEnter and OnModeEnter for Browse mode.  So when you first get to the layout it will sort and then every time you finish a find it will sort again.

                • 5. Re: Sorting issues in layout
                  alexchoh

                  Hi,

                   

                  Thanks for your reply. 

                   

                  Question 1 : I switched to onmodeenter and it works fine.  But should i use onmodeexit instead?

                  Question 2 : How to I force the displayed or active record in the found set to be the first record (after the sort)?

                   

                  Thank you

                   

                  Alex

                  • 6. Re: Sorting issues in layout
                    mw777rcc

                    Question 1 : I switched to onmodeenter and it works fine. But should i use onmodeexit instead?

                    onModeEnter fires AFTER the event has happened where onModeExit fires BEFORE the event happens.  If you ran a script that sorted records and did it with the onModeExit then you would still be in find mode when the script ran. This functionality is better for something like constraining every find that is done by an additional criteria, because it happens while still in find mode.  For your needs you need it to process after the event (change of mode) happens so my recommendation is correct.

                     

                    Question 2 : How to I force the displayed or active record in the found set to be the first record (after the sort)?

                    If you already have an active record and you want that record to be the first record in your found set then you will need to know how many records are displayed on your layout and then jump to appropriate records to cause the screen to shift to the position for which you are looking.  It is the same concept as doing so in a portal but the problem is that a portal has a predefined number of rows.  A list view depends on the size of the screen(unless you set the size of the window and do not allow it to be resized).  I have never tried to do this so it would be just a theory, but my first idea was to use something on each record (on record load, a calculation within conditional formatting, etc) to capture what record number was the highest record number shown.  (items off screen should not trigger these calculations) Once you know how many records are shown on the screen then you can jump past your record to the last one that you want to see on the screen and then jump back to your record. 

                    Example:  There are 30 records shown on the screen right now.  Your record is record number 43.  Use Go To Record [72] (43+29) and then Go To Record [43]  This will snap the layout to the appropriate record set and then put the focus on the record that you want.