6 Replies Latest reply on Aug 7, 2013 9:49 PM by TaylorJansen

    How to change value list of a field by script?

    TaylorJansen

      Title

      How to change value list of a field by script?

      Post

           I have a layer with 2 fields. The Field B depends on value of Field A, a conditional value list.

           Is there any way to change which value list to use for Field B based on the value chosen in Field A?

           Say if Field A= XXX, then use value list XXX in Field B, if Field A =YYY, then use value list YYY in Field B

        • 1. Re: How to change value list of a field by script?
          shilpas@metasyssoftware.com

               Refer the post http://forums.filemaker.com/posts/c8a90842f6?page=1

               here PhilModJunk has submitted the demo file (fp7), https://www.dropbox.com/s/8levaz6deiyzjr8/LayoutObjectVisibilityControlDemo.fp7 which you can refer. Check the 'transparent tab control' technique.

          • 2. Re: How to change value list of a field by script?
            philmodjunk

                 Here's thefull list of links that I recommend for learning about conditional value lists. And to answer your specific question, if you want a script to change what values appear in a conditional value list, you design the script to edit the value in the match field on which the conditional value list's relationship is based.

                 There's a lot of overlap between the first two links so you can read one and skim the other. The demo file gives you several examples of different conditional value lists so you can examine them to see how they are set up. If you are using FileMaker 12, you can open this demo file from your File menu to get a converted copy of the demo file that you can examine in FileMaker 12.

                 The last link discusses how to set up a chain of conditional value lists where the value selected in each conditional value list controls the values listed in the next value list.

                 Forum Tutorial: Custom Value List?

                 Knowledgebase article: http://help.filemaker.com/app/answers/detail/a_id/5833/kw/conditional%20value%20list

                 Demo File: https://www.dropbox.com/s/j6qf0z9fnem3uxd/ConditionalValueListDemo.fp7

                 Hierarchical Conditional Value lists: Conditional Value List Question

                 Feel free to post follow up questions here if those links aren't enough to get your value lists working correctly.

            • 3. Re: How to change value list of a field by script?
              TaylorJansen

                   This is not the case.

                   For example: In Person Type Table

              Person ID | Person Type | Department | Subject

                   1                 | Student          | Music            | Piano

                   2                 | Student          | Academic     | French

                   3                 | Student          | Arts                | Drawing

                   4                 | Tutor               | Music            | Violin

                   5                 | Student          | Service         | Piano Tuning

                   6                 | Tutor              | Service          | Recording Engineer

                    

                   For example in the Class table

               Class ID | Department | Subject

                   1               | Music            | Violin

                   2               | Academic    | Japanese

                   3               | Arts               | Painting

                    

                   For example in the Service table

                   Service ID | Service Name     | auto_enter_Service

                   1                  | Piano Tuning      | Service

                   2                  | Studio Engineer | Service 

                    

                   ...to be continued in next post

              • 4. Re: How to change value list of a field by script?
                TaylorJansen

                     ....continued from last post.

                      

                     I know how to set a conditional list. But my problem is in the Subject field of Person Type table.

                     I want the following to happen.

                     If Music or Arts or Academic is chosen in the Department field, then in the Subject field, it uses  value list from Class table to choose Subject.

                     If Service is chosen in the Department field, then in the Subject field, it uses value list from Service table to choose Service Name.

                     So the problem is how to switch between the 2 value lists based on value of Department field. Is there a script to change the value list? 

                     If I choose "value list from Class", it works fine but not for Service. If I choose "value list from Service" then only applicable to Service. Any way to specify which value list a popup list use? 

                • 5. Re: How to change value list of a field by script?
                  philmodjunk

                       This cannot be done exactly as you describe in FileMaker with a conditional value list. But the data in the class and service tables could be combined in a single table and then the standard conditional value list can list values from this combined table of values selecting for either "service" or "Class" subsets of the records in this unified table of values.

                       An alternative approach might be to place two copies of the Subject field in two panels of an invisible  tab control and format each with a different value list. Selecting Service in the Department field can trip a script trigger that performs a script to select the tab panel for copy with the service value list. Selecting a different value causes the script to select the panel with the copy of the field that is formatted with the class value list.

                  • 6. Re: How to change value list of a field by script?
                    TaylorJansen

                         I solved by making 2 layout of the same, for Subject field in one layout i format to use "value list from class table", in another one format to use "value list from service table"

                         Onobjectmodify at the Department field, move to corresponding layout based on which department chosen.