5 Replies Latest reply on Dec 11, 2009 10:06 AM by philmodjunk

    RecordID Question



      RecordID Question


      I'm trying to set up a given file to open with a found set and on the same record as when it was closed. The found set part is simple . . . I've created a global field, let's call it gSet, and the closing script  sets the field with a value. When the file is opened again an opening script performs a find using the contents of gSet on the appropriate field. I thought I could do the same with a field, let's call it gID, by setting it to Get(RecordID) upon closing, then using GoToRecord by calculation using the stored RecordID in gID, but of course the GoToRecord step expects a RecordNumber(not RecordID) that exists in the set found using gSet. Is there no way to make this script step work with a RecordID (which doesn't change)?


      If I close the file with a subset of the set that's found on re-opening, I'd still like to go to the same record as when the file closed. The problem:I may have four records of 75 that are engagements of a given production showing when I close. When I re-open of course I'll have all 75 records of this production but want the focus to be on the last record viewed. It would be simple to have only the one record found but that's not what I'm after. BTW this layout is in Form view.





        • 1. Re: RecordID Question

          I can't see a way to use recordID, directly but there is a way to do this:


          Let's assume you have a serial number field that uniquely identifies each record.


          Define a global number field gCurrentRecord.

          Write a script that saves the IDfield's value in a related table and have this script run when you close the database.


          Create a self join relationship:


          YourTable::gCurrentRecord = YourTableSelf::IDfield


          Now your script can look like this:


          Set Field [gCurrentRecord; Table::fieldwhereyousavedtheID]

          commit Record

          Go To Related Record [From table: "YourTableSelf"; using layout <current layout>]


          As long as the desired record is part of the current found set, GTRR in this form will make your "saved" record the current record without altering your found set.


          Go To Related Records is a very useful tool, but which is very poorly documented. To learn more about GTRR, click the following link:

          The Complete Go To Related Record

          • 2. Re: RecordID Question

            Hi Phil,


            That worked fine. Thanks. I had been considering this before reading your excellent description but had had a suspicion it might be achievable with the GoToRecord step. BTW I've read all you've written on GTRR and as a result have eliminated a few instances of the step and made it iron-clad when necessary by capturing errors. This may be the first time I've used the step where error capturing is redundant! The record HAS to have existed; otherwise the global field could not have been saved with the particular value in the first place. Since the first script runs only on closing the file and a record can't be deleted without reopening the file, it seems foolproof (where have I heard THAT before?).


            • 3. Re: RecordID Question



              A curiosity that I don't have time to play with at the moment...


              RickWhitelaw wrote:

              . . . I've created a global field, let's call it gSet, and the closing script  sets the field with a value.


              For my own curiosity, and hopefully the benefit of others as well:

              My understanding is that globals are "per-user-session".  Would that not therefore end when using the closing script?  I re-insert values into globals on startup because they're blank when I re-open the app.  How does the above 'find and identify' process work with globals that are set at the end of the user session?

              • 4. Re: RecordID Question

                The application isn't running on a server. As far as I can tell, the value is retained for the same user which is the way I want it. Before implementing this it was unpredictable, when opening the file, what record would have focus. This way it's easier to pick up where I left off, or in the ballpark of where I want to be, when I re-open the file. If another user were to log on I expect the global would be reset. Anyway it works well . . . very convenient.



                • 5. Re: RecordID Question

                  When you use Go To Related Record [From table: "YourTableSelf"; using layout <current layout>]


                  the <current layout> option is treated as a special case (it replicates the old "pre FMP 7" GTRR) and no trapping for error codes is strictly necessary.