3 Replies Latest reply on Mar 21, 2016 12:45 PM by CamelCase_data

    Stay on current record after seaching


      If I perform a search from a script, how can I stay on the record I started with inside the found set? Or else sort normally...


        • 1. Re: Stay on current record after seaching

          performing a search changes your found set, so you can't really guarantee screen position or remain on the same record, as it may be omitted or repositioned as the result of your find.


          You might be able to do something if you have a primary key, like this:

          Set Variable [ $id ; yourTable::yourKey ]

          Perform Find

          Go To Record [ First ]


            Exit Loop If [ get(recordnumber) = get(foundcount) or $id = yourTable::yourKey ]

            Go to Record [ Next ]

          End Loop

          This would either leave you on the record you were on before the find, or the last record in the list if that record was omit during the search.

          • 2. Re: Stay on current record after seaching

            Had the same thought as mike.. what if the found set after search does not include the started from record?

            • 3. Re: Stay on current record after seaching

              If you add a field based on your Id using the List of option for a Summary field, you'll get a sorted list of the Ids. You can then easily parse out the position of the ID in that list and use that to Go to Record with the By Calculation option, without having to loop.


              So something like this - can be simplified somewhat if you use UUIDs.



              Set Variable [ $ID; Value:MyTable::ID ]

              Perform Find [ ]
              Set Variable [ $ID_List; Value:"¶" & MyTable::ListOf_ID & "¶" ]
              Set Variable [ $Left; Value:Left ( $Id_List ; Position ( $Id_List ; "¶" & $Id & "¶" ; 1 ; 1 ) ) ] Set Variable [ $RecordNumber; Value:PatternCount ( $Left ; "¶" ) ]
              If [ $RecordNumber > 0 ]

              Go to Record/Request/Page [ $RecordNumber ]

              End If