8 Replies Latest reply on Mar 12, 2009 6:33 PM by comment_1

    Portal records and List command not following portal sort

    ErichWetzel

      Title

      Portal records and List command not following portal sort

      Post

      I have set up a portal showing related records.  The sort of the portal is by date and then by a time. This allows the contents of the portal to be shown chronologically.  The related items in the portal are not always entered in a chronological order.  For example a related item dated 3-10-2009 might be entered after a related item dated 3-11-2009.

       

      The portal will show them in the expected sort order 3-10-2009 then 3-11-2009.

       

      If I ask for a field in the portal, a time for example, to be listed:

      List (related::time)

      the list returns the data in the order the related records were created in rather than the order that the portal is sorted in.

       

      To serve the purpose I have, I need the items returned in the sorted order from the portal not the created order.

       

      The actual use I am trying for is to get a script to generate a list of the related items into a field, essentially listing the date, time started, time ended if there is one and a description of the event taking place.  This is needed in a date and time started order using a Variable $portalrow to represent which portal row to pull data from.  GetValue(List(File::field) ; $portalrow) where I am running a script loop asking for each sequential portal row by incrementing $portalrow and simply asking for the related data. 

       

      I assume that the request I am making is not being performed on the showing portal but rather by default to the creation order of the related records.

       

      Additionally, I seem to be getting inappropriate returns.  Periodically I am being given a related::timeend that is part of another related record not the $portalrow record.  In these strange cases the timeend of the $portalrow record is blank.

       

      Advice?

       

      Thanks - Erich

        • 1. Re: Portal records and List command not following portal sort
          ninja
            

          howdy Erich,

          Thanks for the post...very well described.

           

          You also included that magic word "Script".

           

          Default sort order in a find (as far as I can tell) is creation order.  If you're in a script already anyway, include a sort step before your script ends... Is there a reason this would not work?

          • 2. Re: Portal records and List command not following portal sort
            ErichWetzel
              

            Ninja,

            Thanks for the reply.

            One unclear detail from my post.  What needs sorting is the related group of records.  The sort in the script will be performed on the found items in the main record file because that is where it is being run.  Also, the field I am writing to is in the main record not any of the related records (though I tried that with the same result frustrating result).

             

            I did manually find and sort the related records in the related file to match the portal view in the main file.  No luck.  Same result on running the script.

             

            I am thinking I may have to run a lengthy copy / paste sequence iterating through the portal rows manually.  Not the most efficient method, but I tested and found that I can be into each of the fields needed, in each of the rows, in the order required to compose the list we need.

             

            EDIT : The manual copy / paste is a problem because I will not be able to compare one related item to the next.  I need to check as each item is added if events happen on the same day or at the same place.  So two events at the same place, only insert the place once, two events on the same day, only insert the day once.

             

            -Erich 

            • 3. Re: Portal records and List command not following portal sort
              comment_1
                

              ErichWetzel wrote:
              If I ask for a field in the portal, a time for example, to be listed:

              List (related::time)

              the list returns the data in the order the related records were created in rather than the order that the portal is sorted in.


              List() follows the sort order defined for the relationship, not of a portal  - you could have any number of portals on a layout (or on many layouts), each with a different sort order.


              • 4. Re: Portal records and List command not following portal sort
                ErichWetzel
                  

                That's the conclusion I am reaching with the feedback.  I was worried about the portal issue and made sure to have only the one on the Layout in use.

                 

                Any idea if there is a function which can give what I am looking for?

                 

                Thanks for the clarification.

                 

                -Erich 

                • 5. Re: Portal records and List command not following portal sort
                  comment_1
                    

                  ErichWetzel wrote:

                  I was worried about the portal issue and made sure to have only the one on the Layout in use.


                   

                  That doesn't matter. Portals are layout objects, so Filemaker ignores them in calculations. You wouldn't want your calculation to stop working if there was NO portal at all, would you?

                   

                   

                   


                  ErichWetzel wrote:

                  Any idea if there is a function which can give what I am looking for?


                   

                  I thought I already answered that: go to the definition of relationship, and define the sort order there.

                   



                  • 6. Re: Portal records and List command not following portal sort
                    ErichWetzel
                      

                    You did say to update the relationship sort.  Sorry, stuck on the function / script track since I have been working on this all day.

                     

                    You have it.  With the sort in the right place, the function / script can now give what I need.

                     

                    Thanks again. 

                    • 7. Re: Portal records and List command not following portal sort
                      ErichWetzel
                        

                      I figured out the strange returns too.

                      The inappropriate returns in the original post are the result of empty fields.  The List function does not include an empty field in the list.  In a List each line has content, if a field is empty is does not appear in any way in the list.

                       

                      So if you have :

                      A B

                      1 1

                      2 2

                      3

                      4 4

                       

                      List for A returns

                      1

                      2

                      3

                      4

                       

                      List for B returns

                      1

                      2

                      4

                       

                      If you need to refer to line 3 expecting a blank for B since the field is blank you would be mistaken and will get a 4 instead.

                      • 8. Re: Portal records and List command not following portal sort
                        comment_1
                           What is it that you are actually trying to accomplish here?