6 Replies Latest reply on Jun 13, 2013 6:39 AM by Jason_Farnsworth

    Getting Field names based on values


      Hi there,


      I'm creating a To Do list for my students based on whether work urgently needs doing, needs doing or is complete.


      I currently have the following script which works for a single field:




      Case ( FieldA="URGENTLY NEEDS COMPLETING" ; GetFieldName ( FieldA ))


      Can anyone help me adapt the script so it will look through all the relevant fields (there are around 30) and return all the field names that contain the value "URGENTLY NEEDS COMPLETING"?


      many thanks

        • 1. Re: Getting Field names based on values

          I suggest you take a look at the FieldNames function. This returns the names of all fields on a given layout.


          Build a layout that has all the fields on it you want. Then use FieldNames to fetch a return-delimited list of the field names. You can then loop over the list and use your calculation above to test each one for the presence of your desired string.





          1 of 1 people found this helpful
          • 2. Re: Getting Field names based on values

            Mike's suggestion will steer you in the right direction in the short run, but I think your table structure could stand to be revised if this is something you'd like to keep using for a long time. It sounds to me like you have a table where each record represent's a student's To Do list, and different fields in that table store the different completion statuses for each task. You'll eventually be better served by moving each task to a separate record in a different table and creating a relationship between ToDoLists and Tasks. This is called data normalization, and it will let you do things like assign different tasks to different students, or change the tasks on the to do list over time without wiping out the older data. Any introductory book on FileMaker will describe how and why to do this in more detail.

            • 3. Re: Getting Field names based on values

              Hers's a script that should work


              Go to Layout[ Relevant fields layout ]          *create a layout that has just the relevant fields*

              Go to Field [FieldA]    *FieldA is the first field in the tab order


                If( Get( ActiveFieldContents)= "URGENTLY NEEDS COMPLETING"

                    Set Variable [ $fields; $fields & ¶ & Get ( ActiveFieldName)

                End if

                Exit Loop If [Get ( ActiveFieldName) = "FieldZ"    *FieldZ is the last field in the tab order*

                Go to Next Field

              End Loop

              *$fields will be a list of fields.  Add script steps to do what needs to be done with the list

              Go  to Layout [original]


              If you don't want to use a variable, you could substitute a field for the variable and use the Set Field step.

              • 4. Re: Getting Field names based on values



                This is the exact problem that I am also dealing with, my fields are all calculated values. Will the process still work on fields that have a calculated value?


                Jason Farnsworth

                • 5. Re: Getting Field names based on values

                  Without knowing more details about your solution in particular, I don't see why not.

                  • 6. Re: Getting Field names based on values



                    Could you look at this thread for the details of what I am trying to accomplish?


                    Dynamic Variables