1 2 Previous Next 17 Replies Latest reply on Jun 30, 2012 3:46 PM by jormond

    Setting a file's default table

    DanielShanahan

      I would like to get a list of all the field names of a table. The Design Function FieldNames() works but requires all the fields to be on a layout. I'm in a legacy system where several tables have hundreds of fields, not all of them on a layout.

       

      According to the FMP documentation this function takes two parameters: FieldNames ( fileName ; layoutName ). If the first parameter is empty it will use the current file. If the second parameter is empty the function will return a list of all the fields in the "default table".

       

      What is the default table and how is it set?

        • 1. Re: Setting a file's default table
          MarcDolley

          Wouldn't it just be easier to add a new default layout for each table containing all fields and then using the FieldNames() function on those layouts? To me, that would be the quickest and simplest approach.

           

          Regards

          Marc

          • 2. Re: Setting a file's default table
            comment

            DanielShanahan wrote:

             

            What is the default table and how is it set?

             

            The "default table" is the first table created in the file.

             

            Note also that you can specify a table name, and if there is no layout with the same name the function will return all fields in the table.

            • 3. Re: Setting a file's default table
              steve_ssh

              Michael Horak wrote:

               

              Note also that you can specify a table name, and if there is no layout with the same name the function will return all fields in the table.

              What a gem of information (which I did not know).  Thank you for the tip.

              • 4. Re: Setting a file's default table
                DanielShanahan

                It would, Marc.  I was just trying to understand the documentation a little better.  But you are correct, that would be a fast way of getting the field names.  Thanks.

                • 5. Re: Setting a file's default table
                  DanielShanahan

                  The "default table" is the first table created in the file.

                  Thanks Michael.  It wasn't clear in the documentation.

                   

                   

                  Note also that you can specify a table name, and if there is no layout with the same name the function will return all fields in the table.

                  I agree with Steve - that's a nice little gem.  Thanks Michael!

                  • 6. Re: Setting a file's default table
                    DavidJondreau

                    Which version of FileMaker? With FM12 you can use ExecuteSQL() to access a couple "hidden tables" that provide more nuanced info than their regular FM functions. Try this...

                     

                    ExecuteSQL ( "SELECT FieldName FROM FileMaker_Fields WHERE TableName='Contacts' ")

                     

                     

                    DJ

                    • 7. Re: Setting a file's default table
                      CarstenLevin

                      Daniel writes about the "Default Table":

                      Thanks Michael.  It wasn't clear in the documentation.

                       

                      But, sorry, no. There's no such thing as a "Default Table" in FileMaker, at least not if there are more than one table in the file.

                       

                      And I am nearly sure that there are no difference between the first or the last table.

                      You are not loosing anything by deleting the first table - it has no special attributes or anything else.

                      Could anyone help us by pointing to where FIleMaker mention a special table with special attributes as the default table?

                       

                      Though you could say that a file can have a default layout. And through this via the Table Occurrence also a default table.

                      But you can change the TO behind the Layout and you can change the table behind the TO. Thus the "default table" is not static:-)

                       

                      You could talk about one "Default Table".The table created together with the file. The one most developers will delete as the first thing (or rename and use for something). But this is without any real meaning.

                       

                      Best regards


                      Carsten

                      • 8. Re: Setting a file's default table
                        comment

                        Carsten Levin wrote:

                         

                        Could anyone help us by pointing to where FIleMaker mention a special table with special attributes as the default table?

                         

                        Why not simply read the help on the function in question, FeldNames()?

                        http://www.filemaker.com/11help/html/func_ref1.31.31.html#1029384

                         

                        There, under Description, you will find that:

                        If layoutName isn’t specified, then the field names of the first table created (the “default table”) will be returned.

                        • 9. Re: Setting a file's default table
                          DanielShanahan

                          Interesting.  I referenced the help from Help menu from within FMP 12.  There, the description reads:

                           

                           

                           

                          Description 
                          Related fields are displayed in tablename::fieldname format.
                          
                          If no parameter is specified for fileName, FileMaker returns results for the current file.
                          
                          Note  If FieldNames returns a question mark (?) or the name of only one field, go to the Specify Calculation dialog box and make sure Calculation result is text. Also, you can increase the size of the field on the layout to show more field names.
                          
                          

                           

                          However, in the web based version that Michael reference, it reads:

                           

                           

                          Description
                          Related fields are displayed in tablename::fieldname format.
                          If layoutName isn’t specified, then the field names of the first table created (the “default table”) will be returned.
                          Note  If FieldNames returns a question mark (?) or the name of only one field, go to the Specify Calculation dialog box and make sure Calculation result is text. Also, you can increase the size of the field on the layout to show more field names.
                          
                          

                           

                           

                          Both versions refer to the "default table" in the Examples section.  Since it was undefined in the FMP 12 Help section (from within FMP) and since I had not double checked the web version, I was confused.

                          • 10. Re: Setting a file's default table
                            DanielShanahan

                            Thanks for the reply, David.  Sorry I had not specified the version.  I'm using FMP12.

                             

                            Thanks for the ExecuteSQL() suggestion.

                            • 11. Re: Setting a file's default table
                              comment

                              The difference is not between the built-in version and the web version - it's between version 11 and version 12. I am not sure why they removed the clarification from the Description part, but kept the example as is.

                              • 12. Re: Setting a file's default table
                                Stephen Huston

                                Do you need this list of field names for tables for use programmatically within FileMaker, or are you just wanting a simple way to find out what all the clutter is in this old system?

                                 

                                If not required for some special use within the FM program, the best way to get an overview of the system is the Database Design Report from FMP12 Advanced (tools menu). It will give you all the field lists for all the tables in all of the files in a useful and searchable report.

                                • 13. Re: Setting a file's default table
                                  DanielShanahan

                                  Thanks for your comment, Stephen.  I created a separate database with meta data from the legacy system and I use the table name as a key for one of the relationships.  Its just a tool to help me decipher what is in the legacy system and how it is connected.

                                  • 14. Re: Setting a file's default table
                                    Stephen Huston

                                    It sounds like you are building your own Database Design Reporting (DDR) system. Before going into a lot of effort to recreate the wheel, take a look at the built-in DDR if you have Advanced. I find that the DDR and using BaseElements for diagnosing potential problems revealed by the DDR allow me to identify and clean out legacy system junk very efficiently.

                                    1 2 Previous Next