11 Replies Latest reply on Jun 29, 2014 11:45 PM by nihmbrisby

    Is there a way, like a button, to go back to the last record you viewed

      Title

      Is there a way, like a button, to go back to the last record you viewed

      Post

           Hi,

           I used to use a database that showed you the last 10 records you viewed, which was very practical, ie, if I was on a record and thought, I want to just check if another record has these details too, I would enter the search for this record, view it, then drop down the list of last ten records to go straight back to the other record.

           I guess there could be a script to use in a button to achieve this but I can't work it out.

           I know that you can save searches on fm, however, if the record was in the middle of a group of 50, you have to do the search and wade through the 50 to get to it.

           Can this be done?

           PS in an ideal world there would be a script on a button that would rotate the last 10 records you viewed as my last database, but I think this maybe out of reach for fm.

           All records would be on one table.

        • 1. Re: Is there a way, like a button, to go back to the last record you viewed
          philmodjunk

               The question is whether you need to preserve the current found set and just change current records or not.

               On RecordLoad could perform a script that updates a global variable or global field with the primary key of the current record to form a list of the last N records visited. Selecting from this list of values could be set up to perform a find for that record or, if that value were placed by the script into a global field used as the match field in a self join, Go to related records could be used to return you to that record. GTRR would be the option to use if you just want to change current records without modifying the current found set.

          • 2. Re: Is there a way, like a button, to go back to the last record you viewed

                 Hi Phil,

                 I don't need to preserve any found set.

                 The "On RecordLoad could perform a script that updates a global variable or global field with the primary key of the current record to form a list of the last N records visited." sounds perfect; how do I achieve this? Is there a handy demo file on dropbox with this, or instructions here.

            For last N records visited; I would think it would be useful to show the last 20 records.

                 I have two main tables in my database that I would want to do this for.

                 Thanks for the suggestions, it sounds a lot better than my workaround, which would be to add a check box on each record that I would check as I view records I will probably want to see again later in the day, then just find on this check box.

                  

                  

            • 3. Re: Is there a way, like a button, to go back to the last record you viewed
              philmodjunk

                   Do you know how to create a conditional value list? Once we have a list of values for most recent records, that's one option. A portal that lists them where you click a portal row button to select one could also be used. Both rely on using the list of values as the match field in a relationship.

                   OnRecordLoad might perform a script like this to build the list in a global field. (We could use a global variable, but with a field, we've got our match field for a relationship.):

                   Set Field [ YourTable::gLast20Visited ; List ( RightValues ( YourTable::gLast20Visited ; 19 ) ; YourTable::__pkYourTableID ) ]

                   This appends the primary key of the current record to the end of a return separated list of values, but then "prunes" the list to just the most recently appended 20 values.

                   A self join relationship:

                   YourTable::gLast20Visited = YourTable 2::__pkYourTableID ]

                   would then match only to the most recently visited 20 records in YourTable. YourTable 2 would be a second Tutorial: What are Table Occurrences? of YourTable.

              • 4. Re: Is there a way, like a button, to go back to the last record you viewed

                     Hi Phil,

                     Thanks.

                     I'll try to make this work and let you know tomorrow. From what I know of FM it looks logical and I should be able to get it to run.

                      

                • 5. Re: Is there a way, like a button, to go back to the last record you viewed

                       Hi Phil,

                       Something you said made it click. I was overcomplicating the idea, and reading your advice, I thought it would be a lot better to keep it simple.

                       I've added a new radio button called ROLODEX. If I think I'm going to need to keep going back to a record during the day I click this now.

                       At the end of the day I replace field with "".

                       It's working great.

                       Thanks

                  • 6. Re: Is there a way, like a button, to go back to the last record you viewed
                    symbister

                         Thanks Phil, great trick, but I'm sorry to say I think there's a flaw in the logic :

                         "Set Field [ YourTable::gLast20Visited ; List ( RightValues ( YourTable::gLast20Visited ; 19 ) ; YourTable::__pkYourTableID ) ]

                         This appends the primary key of the current record to the end of a return separated list of values, but then "prunes" the list to just the most recently appended 20 values."

                         what this seems to do is prune the list to the last 20 entries, including the carriage returns.... Through trial and error, I found I had to set my RightValues second parameter to 37 to get the last twenty entries.

                          

                    • 7. Re: Is there a way, like a button, to go back to the last record you viewed
                      philmodjunk

                           A parameter 37 makes no sense.

                           RightValues does include an extra return after the 19th value. I had assumed that List would omit that extra return as it is supposed to omit empty values from the list, but what you report suggests that it does not treat the return as an empty value. There are ways to enclose RightValues inside a left or middle function that removes that unneeded return.

                      • 8. Re: Is there a way, like a button, to go back to the last record you viewed
                        symbister

                             makes no sense .. but works perfectly

                        • 9. Re: Is there a way, like a button, to go back to the last record you viewed
                          symbister

                               in my case, I'm wanting the last nine records browsed, so I have a portal to the second TO, of eight rows, set to Initial Row 2 (to exclude current record)which is updated OnRecordLoad, using Phil's routine.

                               Through trial and error, I found that to display n records, the second parameter of the RightValues expression had to be set to (n/2 - 3), tested in edit box, checkbox, dropdown and popup, all same results, also doesn't appear to matter if gLastnvisited is Text or Number, so for 9 records, parameter is set to 15.

                                

                          • 10. Re: Is there a way, like a button, to go back to the last record you viewed
                            philmodjunk

                                 Yes but I'm thinking that your value of "37" won't continue to work in all situations as it appears you had to increase the number to adjust for the presence of return characters occupying locations in the list of values--and that's something that will vary each time you interact with your layout.

                                 I think that you'll find that if you use this calculation, things will work out more simply:

                                 Let ( theList =RightValues ( YourTable::gLast20Visited ; 19 ) ; List ( Left ( TheList ; Length (TheList ) - 1 ) ; YourTable::__pkYourTableID ) )

                                 The code: Left ( TheList ; Length (TheList ) will strip off the extra return that's messing things up.

                            • 11. Re: Is there a way, like a button, to go back to the last record you viewed
                              nihmbrisby

                                   Straight up copy and pasted this code (changing fields of course) and it works awesome! Thanks Phil. 

                                    

                                   PS My bad didn't realize this was an old thread blush.