6 Replies Latest reply on Jan 6, 2015 6:02 AM by FMuserHuck

    Formula to choose from a value list

    FMuserHuck

      Title

      Formula to choose from a value list

      Post

      Is there any way I can write within a script the choosing from a value list? For example, if I have a dropdown menu, field name "Produce", that includes Apples, Oranges and Bananas, from the value list "Fruit" is there a formula to automatically choose Oranges upon a new record entry?

        • 1. Re: Formula to choose from a value list
          philmodjunk

          In File Options, select the auto-enter tab and put the text "Oranges" without enclosing quotes into the data box.

          Or use the calculation option with:

          GetValue ( ValueListItems ( Get ( FileName ) ; "YourValueListNameHere" ) ; 2 )

          to auto-enter the second item from the list.

          This second item will update automatically to enter different data into newly created records each time the second value that appears in the value list changes.

          • 2. Re: Formula to choose from a value list
            FMuserHuck

            Okay, I'm gonna make things a bit more complicated here...

            Your formula did help, and makes sense - thank you! Here's the actual, more complicated issue I'm trying to solve...

            I have a global field with a dropdown list of frequented layouts. I studied a FM solution and figured out how to attach a script trigger to the field so that when I choose "Customers" in the list, it takes me to the Customer layout, when I choose "Orders" it takes me to Orders etc. etc. Works like a charm.

            The problem only occurs when I use the standard status toolbar menu instead of my global field. So let's say I'm in Orders, and instead of using my field, I use the toolbar dropdown menu to take me to Customers. On that layout, the global field still reads "Orders" even though I'm in the Customer layout now.

            I thought I could add a step in the script to change the global field info upon entering a particular layout - hence my original question. If that is the answer, I'm struggling to modify it within the script trigger. Wondering if there's a simpler option now? (I keep going back to that FM solution and I can't find the answer there.) Stumped.

             

             

            • 3. Re: Formula to choose from a value list
              philmodjunk

              The OnLayoutEnter trigger can certainly perform a script to do this.

              It can be a single set field that explicitly set's the field to a value. That requires one script for each layout.

              But you can also use a single script with all the layouts:

              If the layout's name matches the value in the value list, you can use:

              Set FIeld [ Table::GlobalField ; Get ( LayoutName ) ]

              And if they do not, you can pass the desired value as a script parameter to the script and use:

              Set Field [Table::globalField ; Get ( ScriptParameter ) ]

              • 4. Re: Formula to choose from a value list
                FMuserHuck

                I went with the OnLayoutEnter trigger and it works beautifully. Thank you!!

                • 5. Re: Formula to choose from a value list
                  philmodjunk

                  Hmmm, well all three suggestions use the OnLayoutEnter trigger...wink

                  • 6. Re: Formula to choose from a value list
                    FMuserHuck

                    Guess I didn't even realize that. I'm self-taught, so while I've been able to make things work eventually, actual terms are still pretty foreign to me! I appreciate your help.