9 Replies Latest reply on Dec 7, 2011 1:10 PM by philmodjunk




      Scripts & Buttons


      I have a layout in Filemaker with a bunch of buttons.  Each button has a name (see screenshot).  I would like to be able to create a script that when you click on the button it sets the name of a field in a table to the same name of the button.

      I know I can create 50+ different scripts (one for each button), but I would prefer to create one script (I'm lazy!).

      Any suggestions?


        • 1. Re: Scripts & Buttons

          instead of a script, you can define each button to Set Field.  If you name each button from the position tab of the inspector you can use the Get ( ActiveLayoutObjectName ) as the calculated result to insert into that field.

          If you want to use a script you can pass the button name as a script parameter then set field  Get ( ScriptParameter )

          • 2. Re: Scripts & Buttons

            I see 28 buttons. Does:

            "when you click on the button it sets the name of a field in a table to the same name of the button."

            mean you have 28 different fields in the same record?

            If so, I suggest a structure change so that you have multiple records in place of multiple fields. These can be records in a related table.

            • 3. Re: Scripts & Buttons


              How do I "pass the button name as a script parameter"?



              I have one field only - just lots of buttons.  I want to set that one field as the name of the button selected.


              • 4. Re: Scripts & Buttons

                when you format the button to run a script, there is a little window near the bottom for script parameter.  Set that to "Alligator" for the Alligator button and so on for each of them.  That way there is only one script but the text you enter in that script parameter wil be what gets entered into the field.

                • 5. Re: Scripts & Buttons


                  Makes sense.  Am I correct then that I need a script for each of my buttons?  Is there no way to make the Script Parameter the name of the button (the text on the button)?


                  • 6. Re: Scripts & Buttons

                    That is what I was trying to say.  You only have to define the script parameter for each button, all of them run the same script.

                    Or if you name each button to the Text you want in the inspector, you can use Get(ActiveLayoutObjectName) to capture that name.  With that you would not need a script at all, just have the button perform a Set Field to that calculated value.

                    • 7. Re: Scripts & Buttons

                      Totally get it now!  Script Parameters was something new for me!  Thank you so much for all of your help!!



                      • 8. Re: Scripts & Buttons

                        Phil taught me about them not too long ago.  Can really help on keeping the # of scripts down.

                        • 9. Re: Scripts & Buttons

                          Once upon a time in an older version that did not support script parameters, I had to create 26 scripts--one for each letter of the alphabet for 26 matching buttons...