7 Replies Latest reply on May 15, 2012 5:26 AM by joris.bruijnzeels

    Script in a Dropdown List

    leoff

      How can I create a script in a dropdown menu??

       

      Thanks all...

       

      Leon~

        • 1. Re: Script in a Dropdown List
          Stephen Huston

          I assume you want a pop-up menu on a field from which you may then pick one of several scripts which could be run from this field/menu.

           

          I do it this way:

          1. create a value list of the menu items (scripts), and attach it to the field, which is formatted as a pop-up menu on that value list
          2. write a script which uses a series of IF and ELSE IF tests based on the content of the field (matches to the VL choices)
          3. use the Perform Script step in each IF and ELSE IF section to run the script chosen
          4. Set a field trigger on this pop-up menu field to run the script onObjectModify
          5. Put an option in the script to reset the value of the field at the end of the script to something like "Choose Script Here" or whatever os more appropriate, and set the IF tests to exist the script if it contains this default value.

          Your script might need a bit of tuning to get exactly the effect you want, but this will give it the basic functionality of a pop-up menu of scripts.

          • 2. Re: Script in a Dropdown List
            leoff

            Much thanks...sounds complex, is it?

             

            L~

            • 3. Re: Script in a Dropdown List
              Stephen Huston

              Not really: a Value List, a script, and a script trigger on the formatted field.

               

              I have one such script that has about 25  ELSE IFs, but they are all essentially the same:

               

              If [ menuField = "Choose A Script to Run" ]

                   Commit Record

                   Exit Script

              ElseIf [ menuField = "Script Name Whatever" ]

                   Perform Script [ choose your script ]

              ElseIf [ etc... to the end...

                   ...until...

              End If

              Set Field [ menuField ; "Choose A Script to Run" ]

              Commit Record

              Halt Script

              • 4. Re: Script in a Dropdown List
                leoff

                By the way, works like a charm! MUCH thanks....appreciate your simplify it!

                 

                Leon~

                • 5. Re: Script in a Dropdown List
                  joris.bruijnzeels

                  To run your script, you could try the following too, it could save you the headache of having multiple IF's

                   

                  Set Variable [ $script ; Substitute ( Get ( FilePath ) ; "fmnet:/" ; "fmp://" ) & "?script=" & $your_script &"&param=" & $your_script_parameter ]

                  Open URL[ $script ]

                  • 6. Re: Script in a Dropdown List
                    mbraendle

                    joris.bruijnzeels wrote:

                     

                    To run your script, you could try the following too, it could save you the headache of having multiple IF's

                     

                    Set Variable [ $script ; Substitute ( Get ( FilePath ) ; "fmnet:/" ; "fmp://" ) & "?script=" & $your_script &"&param=" & $your_script_parameter ]

                    Open URL[ $script ]

                     

                    Undocumented feature? I see nothing in the FileMaker Help of FM 11 (both in "Open URL" script step and "Opening shared databases remotely using a URL") that one could attach a script name and script parameter to the URL.

                     

                    A quick test showed me that this does not work.

                    • 7. Re: Script in a Dropdown List
                      joris.bruijnzeels

                      My mistake, I copied this from a FM12 solution (in which I can say it works perfectly*).

                       

                      I've tried the following with 11 Pro Advanced but it looks like this is a Go-only feature. YMMV.

                      http://help.filemaker.com/app/answers/detail/a_id/7786/~/opening-files-using-the-fmp7-script-protocol-with-filemaker-go

                       

                      * Edit: I did not realize this is a new feature of Filemaker 12. It's incredibly handy though