7 Replies Latest reply on Jun 10, 2016 10:58 AM by user26705

    Script to Pick a List Item

    user26705

      I would like to use a script (executed from a button) where when clicked - the script sets a status for a field.  The field is a "pop-up menu" and the user can update the status on their own - but if they click the button the script will automate 4 or 5 different steps and make their life easier.

       

      I have tried "Go To Field" and "Set Field" and even though I attempt to set the field = to a value - the field only displays a 0. 

       

      Any ideas on how to develop this script or pointers would be welcome.

       

      Thank you!

        • 1. Re: Script to Pick a List Item
          RickWhitelaw

          To which four or five steps do you refer? The question isn't quite clear. Perhaps be more specific and detailed and you will get help from someone here.

          • 2. Re: Script to Pick a List Item
            ErikWegweiser

            Hi. Is the number you're setting in the script a number? If so, is it possibly formatted in the layout to display a boolean value (0 or 1)?

             

            Also check your Set script step to make sure it is setting, for example the text value "Complete" and not evaluating a formula that results in a "0" number.

             

            Without seeing your script steps, I can't picture other issues yet.

            • 3. Re: Script to Pick a List Item
              siplus

              can you tell us how the value list displayed by the popup menu is defined ?

              • 4. Re: Script to Pick a List Item
                user26705

                Here are further details...

                 

                The screen has a "pop-up menu" control that uses a value list.  The list has four values (apple, oranges, pears, mangos) - thus allowing the user to select one of the four values set the underlying field.  The user is not allowed to modify the list or set their own values and this is set appropriately in the inspector.  We will call this control Fruit Choice.

                 

                All of that works...what I would like to do is have a script that accomplishes the following when a button is clicked:

                 

                1. The "fruit list" pop-up should be set to "mangos"

                2. There are some math calculations performed and the results saved in another table. (this is working)

                 

                The issue I am having is that when the user clicks the button - instead of "mangos" appearing - nothing happens - the value in the field is not changed..

                 

                My current script is as follows:

                 

                Set Field by Name [tblLeads::FruitChoice; tblLeads:FruitChoice = "mangos"]

                ....calculation stuff...

                 

                Any help you can provide or insight is appreciated.

                 

                ***no fruit has or will be hurt in the development of this solution.  All development is being monitored by the fruit growers association of America.

                • 5. Re: Script to Pick a List Item
                  erolst

                  user26705 wrote:

                  Set Field by Name [tblLeads::FruitChoice; tblLeads:FruitChoice = "mangos"]

                  Set Field by Name sets the field that is stored in the expression you pass it as first parameter – in that case the field tblLeads::FruitChoice (so unless that field holds a field name, nothing happens). What you actually want is simply set that field itself, so use …

                   

                  Set Field [ tblLeads::FruitChoice ; …

                   

                  And the result you want to write is just "Mangos" – but this expression …

                  user26705 wrote:

                  tblLeads:FruitChoice = "mangos

                  … resolves to either True or False; so if the first parameter would be a valid field reference, you'd write the the value 0 into that field.

                   

                  Anyway, what you want is …

                   

                  Set Field [ tblLeads::FruitChoice ; "Mangos" ]

                  1 of 1 people found this helpful
                  • 6. Re: Script to Pick a List Item
                    siplus

                    ***no fruit has or will be hurt in the development of this solution. All development is being monitored by the fruit growers association of America.

                     

                    Given that Filemaker is a subsidiary of Apple, this elucidation is fundamental and grants you further help on this topic and others that you might submit to us.

                    • 7. Re: Script to Pick a List Item
                      user26705

                      erolst - thank you for the solution and taking the time to explain the background of it!