2 Replies Latest reply on Dec 11, 2013 9:34 AM by JimBessette

    Can a script keep context when switching and reverting record in different table

    JimBessette

      Title

      Can a script keep context when switching and reverting record in different table

      Post

           I'm in table A.  I have a portal (table B) on this layout, but I do not want to be able to edit the fields in the portal (I just want to be able to add new records to it).  So, I've created a button on "layout A" to add a related record in the layout for table B.  My script takes _pkID from table A, and does a new record request in Layout B, where the user needs to choose a field.  Since the new record is now created, it's essentially a "blank" record (yes, it has my pkid, but not much else).  If the user clicks a button to cancel the addition, I need to revert the record (removing the "blank" record).  That all works fine, but now the user is on a different record in table B, not the user from whence I came (from table A).  I'm wondering how to "keep track" of the user, so when I want to go back to that user on layout A, I can.  I don't want to do a find, because then I'm in table A in a "found set".  The original user may not even have any related records in table B, so I can't just do a find on the original user and then GTRR in table A.  I don't have much experience with using script parameters, but that seems like it could be a way to store the ID of the user and use it in some way.  There are some other scenarios on layout B which I have to recover from also, but the main thing seems when I handle them, I no longer have the context of the original user, to get back to Layout A for that user.

           Hope that makes sense.

           Thanks, Jim

        • 1. Re: Can a script keep context when switching and reverting record in different table
          philmodjunk

               There are several scenarios you can play with.

               You could put a "cancel" button on your layout B that both deletes the new record and also returns them to Layout A.

               You could use a scripted find or Go To Related records to pull up a found set on Layout B that consists of only the records linked to the current record on Layout A. Special handling would be needed if you use GTRR and this is the first such record.

               You could also open a custom dialog with input fields to collect all the data for the new record. If the user clicks Ok, the script continues, creates the new record and returns the user to the original layout. If they click cancel, the dialog is closed and no new record is created.

               You can also set up global fields on a layout---possibly shown in a new window and a save button creates the new record, populates the fields from the global fields and the ID of the current Layout A record and returns the user to the original layout. A Cancel button just clears the globals and returns the user to the original layout or window.

               And now with FileMaker 13, I can see how a PopOver button might be used for such a purpose....

          • 2. Re: Can a script keep context when switching and reverting record in different table
            JimBessette

                 Thanks for the answers Phil.  I really like the idea of opening a custom dialog BEFORE the record is created.  At one point, I made the button on layout A just go to layout B and make the user click another button to create the new record.  I abandoned that for some reason (can't recall, but I'm sure it was some issue with reverting and getting back to layout A).   Since it's only one field that needs to be selected for this new record, I like the idea of doing all the prompting first, then creating (or aborting).    I really want to have a drop down for the user to choose the field though, so I'm not sure that'll work.  

                 The global fields on a layout thing seems doable too.  Will require some more research on my part.

                 PopOver button?  I AM on 13 now.  I'll google that.  :-)

                 THANKS for the ideas.