6 Replies Latest reply on Jul 14, 2017 4:54 AM by beverly

    Swapping records


      Hello there,


      What is the easiest way to swap the contents of two records?

      I have a table that is related to another table. The record's number in this table is very important. i.e. the first record has a priority over other records and etc.


      any help would be very really appreciated,

        • 1. Re: Swapping records

          Swap the value of that record number field and that should do it.

          • 2. Re: Swapping records

            Good idea, but how to reach to record number. Suppose you have a portal of related records and always the most important record would the one on the top

            • 3. Re: Swapping records

              You'll need to provide more detail on what you are trying to do.


              I can note that a portal can be sorted so if there's a field whose value indicates which portal record is most important, the portal's sort order can include that field in the sort to pull it to the top.

              1 of 1 people found this helpful
              • 4. Re: Swapping records

                Thanks phil so much.

                • 5. Re: Swapping records

                  If you are extremely careful, you could do an export (as FileMaker file) of ALL the fields on the records you want to swap, open the exported file, sort the records the way you want them to be. Then, back with the original found set (of 2 records in your case?), do an import of that data, with 'Arrange By: Matching Names' and 'Import Action: Update existing records in found set'


                  Only use the 'Update existing records in found set' import option if you are being very careful. But, if I correctly understand what you are trying to do, this will accomplish your goal.


                  If you just want to sort a portal by some criteria other than "creation order", what philmodjunk said is the right way to go: sort the portal. My instructions above are ONLY for if you have some important reason you want the non-sorted order of the records to be changed.

                  • 6. Re: Swapping records

                    I almost always have a serial number field on all tables:

                    sortOrder (number, auto-enter serial)

                    This is "unique to a point", as the sorting will be by that number and then by the creation order. So uniqueness is not necessarily important. In addtion, a number field can be more than integers for sorting. (3.5 comes after 3, but before 4).


                    I can use variables and scripting to physically swap the sortOrder values between two records (related or otherwise). I can also add fractional amounts to change the sort. I may allow (at times) to have the user change the values. I may sort by other field(s) and then Replace the values within the sortOrder field for a found set.


                    The point is that these values need NOT be sequential series of integers, but merely numbers that can be used to sort the records.

                    -5, 2, 3, 4.01, 10, 12, 100, 100.35

                    for example, are sorted by the values, but are not directly an ordered series of integers.

                    With this flexibility, I can 'reorder' records using any of the methods above.

                    NOTE: these must be numbers, as TEXT will sort these differently!


                    There can be more ways to get these records in the order desired!


                    1 of 1 people found this helpful