10 Replies Latest reply on Oct 22, 2015 4:33 AM by sreese

    Easy ways to update layout references

    sreese

      Greetings everyone please forgive the length of this post.I don't know if others have used this methodology or not, but I am interested in getting some feed back.

       

      I have developed a solution to my interface updating issues. Mainly find all of the scripts that may use a layout and point them to a new one without a lot of hassle. It involved a few scripts and 2 extra tables in the database, but for the ease of updating it was more than worth the minimal resources required for such a task.

       

      These are the two tables I came up with.

       

      To start out with I needed to be able to get the system ids and store them into the LayoutIDReference Table. With some research I was able to find out that I could get the layout names and numbers with the command LayoutNames(Get(FileName)) and LayoutIDs(Get(FileName)). I then wrote the script below to parse the data and store it into the table. (There may be a more efficient way, but this was a quick brush at it.)

       

       

      The data returned from that script looks as follows:

       

      After I had that working I created the second table.

      This table contains the ID to be referenced by the scripts, the layout id (which is a drop down list that shows the names of the layouts), the name of the Window if need be, and a description field so I can remember what each one is for quickly and easily.

       

      When I original designed this I was looking to do windows that centered in the screen and allowed a user to edit an item. So this is the script I came up with

      It runs a couple of SQL queries to get the information needed to create the window and go to the correct layout. Then it will resize the current window from full screen to almost full screen and create the new window followed by going to the correct layout by calculation.

       

      If it cannot go to the correct layout because I've renamed a layout and haven't reran the get layout names script it will perform this function automatically.

       

      If for some reason it fails a second time it will then close the window, return the first window to its original size and display an error message to the user. When I finish it the script it will also send an email to the developer letting them know of the error.

       

      I pass the ID parameter in this script to get the correct result from the layouts table.

       

      So now when I wish to rework a layout I can duplicate it, make all of the needed changes, and then update the layouts table to point the scripts to the new layout number and all of the other scripts will be fixed.

       

      I am in the process of writing a script that doesn't create a new window every time either.

       

      Anyhow, I was pretty excited to figure this time saver out. Let me know what you think!

        • 1. Re: Easy ways to update layout references
          siplus

          So now when I wish to rework a layout I can duplicate it, make all of the needed changes, and then update the layouts table to point the scripts to the new layout number and all of the other scripts will be fixed.

           

          What about GTRR ?

           

          Go to Related Record [Show only related records; From table: “TestAPErr”; Using layout: “TestAPErr”]

          • 2. Re: Easy ways to update layout references
            sreese

            siplus wrote:

             

            So now when I wish to rework a layout I can duplicate it, make all of the needed changes, and then update the layouts table to point the scripts to the new layout number and all of the other scripts will be fixed.

             

            What about GTRR ?

             

            Go to Related Record [Show only related records; From table: “TestAPErr”; Using layout: “TestAPErr”]

             

            What happens if I am going to a layout that isn't related to the first record?

             

            For go to related record I can use the same premise and have it go to related record by layoutname by calculation like I did in the other.

            • 3. Re: Easy ways to update layout references
              sreese

              siplus I am not certain that I understood your question correctly.

               

              There is not a 100% easy way to make this work for GTRR, but I have come up with something in the interim. I added a second parameter to the script so it will pass the variable back and then you can use get (scriptresult) to determine the layout by calculation.

               

               

              I still have to figure out how to do an error check for the GTRR before passing the variable back, but as long as the table is updated first it shouldn't have any problems.

               

              You now call this script by doing something like the following:

               

              Perform Script ["Change Layouts ( windowId; type )"; Parameter: List ( "windowId" ; "GTRR")] or instead of GTRR you can use NewWindow to make a new window, or switch to switch the current window.

              • 4. Re: Easy ways to update layout references
                siplus

                sreese, you did a wonderful job, but our solutions are full with GTRR where the layout to go to is explicit, i.e. by name.

                 

                Should one rename that layout, Filemaker will fix the scripts.

                 

                Should one DELETE that layout, because a better one has been created...

                • 5. Re: Easy ways to update layout references
                  sreese

                  siplus - With the second script I just posted it will return the layout name to the calling script.

                   

                  I don't think it is possible to include the go to related record step inside the script, but by returning the variable you can use the GTRR command and specify using layout: Layout Name by Calculation: Get (ScriptResult) and it will pass you to the right layout also.

                  • 6. Re: Easy ways to update layout references
                    sreese

                    Also since I didn't mention this in the last post, the results of the script are the actual layout name, not the number referred to by the underlying layout id.

                    • 7. Re: Easy ways to update layout references
                      Extensitech

                      Just my two cents, if it's worth that much.

                       

                      We actually don't use GTRR (or use it sparingly, at least) because it can't be abstracted. We do finds, which can be abstracted.

                       

                      We have a script that accepts parameters such as table, fld/val pairs, multiple requests, whether to omit, etc.

                       

                      We actually just developed a "drill-down" button/field, where the field is a utility global from the target table, and its (custom function) parameter constructs the find parameter based on the relationInfo between the layout TO and the target TO. If the related TO is too far away, it just does a find request for each related key.

                       

                      PITA, as siplus would say, but worth the effort in the long run, at least until GTRR will accept a layout name by calculation.

                       

                      Also... we use field names for go to layout, so that if we want to deprecate a layout, we make it start with "old" or something, and name the new layout the same as the old layout's original name. Our primary/standard layouts also have a strict naming convention, using TLA's (three-letter-abbreviations), so that from a TLA we can determine the name of, for instance, the main layout or the main list layout. We'd only use a full layout name for very specific layouts (of which we have few).

                       

                      Just some fuel for the fire. :-)

                       

                      Chris Cain

                      Extensitech

                      • 8. Re: Easy ways to update layout references
                        sreese

                        In FM 14 you can do go to related record by layout calculation. At least that's what the gtrr command says.

                         

                        Sent by Outlook<http://taps.io/outlookmobile> for Android

                        • 9. Re: Easy ways to update layout references
                          Extensitech

                          True.I misspoke.


                          I was weighing in on siplus's comments, and got it mixed up in my head with the original topic.


                          It's not the the layout can't be abstracted in GTRR, it's that the TO can't be. The TO still has to be picked from a list.

                           

                          Goes to show how often I use gtrr.

                           

                          Sorry if I caused confusion.

                           

                          Chris Cain

                          Extensitech

                          • 10. Re: Easy ways to update layout references
                            sreese

                            Extensitech, I haven't done a method like yours and I'm sure it works great too. I'm a big fan of new ideas and other ways to do things. Its why I shared the one I came up with.

                             

                            I had thought of something like yours, but on updates there are times I don't always want to keep the layout named the same thing either. In the past I've always hated using layout name by calculations because I would rename a layout and then it would break a bunch of scripts and I would have to fix them.

                             

                            I'm going to keep working on cleaning this up and make it as modular as possible. Here at work we have a massive multiple file solution with several hundred gigs of non-image data (terabytes if you count images). Updating our interfaces has always been painful, and this idea hatched out of not having a super easy way to migrate from an old interface to a new one.