5 Replies Latest reply on Oct 20, 2009 1:40 PM by Spritzel

    Scripting the "Specify field..." option



      Scripting the "Specify field..." option


      I want to display detailed information for multiple products in 50 states by state. Rather than create a separate layout for each state, I would like to create one simple layout and replace a field on the layout with a different field by using a script to change the field. I can do this manually by entering layout mode, right-clicking on a field, choosing "Specify field..." and selecting a different field. I would like to do this by scripting but I can't figure out how to change to a different field in a way that mimics the "Specify field..." option. This would save me an enormous amount of work. Please help!

        • 1. Re: Scripting the "Specify field..." option

          I suggest rethinking your database design. While you could just define a global text field and use Set Field to store different text in that field, a few small changes to your database would make that unecessary.


          Let's pretend that your table has the following fields:


          Product ID

          PRoduct Description


          In layout mode, place your State field in the header of your layout and place fields like Product ID and Product Description in the body.


          Enter find mode and enter a state name such as "Iowa" into the state field, Click perform find. Sort your found records if you want. You'll see "Iowa" at the top of your report. Try this again and enter "New York" as the state to be found. Now you'll see "New York" at the top of your report pages.


          Will that do what you want?



          • 2. Re: Scripting the "Specify field..." option



            Phil's suggestion is pretty good.

            Another way is to create a "Report" field and self join from "Report" to "State".


            On a layout based on TO2, put "Report" in the header and pertinent data (from TO1) in the body in list view.

            Create a value list based on "State" and apply it to the "Report" field.


            Now when you select a state from the dropdown in the header, the related records (all of that state) would appear below.


            It accomplishes the same thing as the find, but without the find operation.

            • 3. Re: Scripting the "Specify field..." option

              Thanks for both suggestions; either has the potential to solve my issue.  I'd like to try Ninja's approach first, but I am puzzled by the terminology used in the reply.  What do "TO1" and "TO2" represent? 



              • 4. Re: Scripting the "Specify field..." option



                Sorry for the abbreviation...Table Occurences 1 & 2.


                Just to make sure it's clear...I'm NOT talking about two tables, but two occurrences of the same table on the relationship graph.  Joined together...thus "Self-join".


                Cool thing...joining a table to itself ;)

                • 5. Re: Scripting the "Specify field..." option

                  Thanks, Ninja.  I figured it out by looking up "self-join" in FMP's help feature.


                  Now I have a bit of work to do.  I really appreciate the assistance I've received!