Jump to content

Conditional Value Lists using a ValueList table?


gczychi

This topic is 2036 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi,

being inspired by Matt Petrowsky’s YouTube video (Lesson #2: Scriptology Mastery Course FileMaker; BTW a great video series!) I added a "ValueList" table to my solution and it works just fine.

However, I can’t make conditional value lists work. I'm lost!

In the example that Matt gives, you set up a ValueList table containing all the category/value pairs of your whole solution and make a self joined relationships to that table for all value lists you would like to see. Keys are text constants that you define that hold the exact category names. Please see below the attached ValueList Table.jpg definition and the ValueList Values. In my solution I have a "Fahrzeugklassen" value list and two other value lists that are dependent on that list. For example, when I choose the item "PKW" from the Fahrzeugklassen list, I would like to see all values of the PKW value list and insert the Enum of that value into my table.

In my table Fahrzeug:: I have two fields, Fahrzeug::Fahrzeugklasse_enum and Fahrzeug::Kategorie_enum that hold the Enum numbers of the ValueList::  When I click on the field Fahrzeug::Fahrzeugklasse_enum, I see a list of all Fahrzeugklassen (see picture Fahrzeug Layout 1). When I choose one, it inserts the corresponding Enum number of ValueList and displays ValueList::TheValue. That works using a self joined relationship with a global "Fahrzeugklasse" as the key (see below TO.jpg and Value List Definition.jpg).

Fahrzeug::Fahrzeugklasse_enum is now filled nicely and I would like to choose a sub category depending on that value. In my example, it is "11", meaning "Agrarfahrzeuge" (agriculture vehicles). When I now click on Fahrzeug::Kategorie_enum, I would like to see all possible values depending on that "11-Agrarfahrzeuge" value: "15-Traktor", "16-Transportfahrzeug" and "17-Andere".

What do I have to do? What kind of fields and relationships do I have to create?

Thanks so much for your help!

Gary

ValueList Table.jpg

ValueList Values.jpg

Fahrzeug Layout 1.jpg

Fahrzeug Layout 2.jpg

TO.jpg

Value List Defintion.jpg

Link to comment
Share on other sites

  • 2 weeks later...

SOLUTION

Since no one seems to be interested enough, I thought I come up with a solution (more than a hack, but hey, it works ;-)

Here again, the categories:

Main Category «Vehicle»:   «Car», «Agricultural Vehicle», etc.

Sub-Category «Car»:   «Roadster», «Limousine», «Van», etc.

Sub-Category «Agricultural Vehicle»:   «Tractor», «Transport Vehicle», etc.

Whenever I choose «Car» as vehicle, I want to see in my sub-category value list «Roadster», «Limousine», etc. When «Agricultural Vehicle» is the main category, I want the second value list to show «Tractor», «Transport Vehicle», etc.

So, this is what to do:  You go about it exactly the same way as before (for a normal value list):  Set up a 1) global field in your ValueList:: table, add a 2) self-joined Table Occurence of ValueList:: using the previously defined global field for the relation, add a 3) number field in your Layout table containing the value that the user will choose (my table name is Fahrzeug::) and 4) add a value list the same way like before.

The only thing slightly different is the global field in ValueList. It mustn’t be a calculation field anymore, but a normal text field — still global. It’s value needs to change whenever the main category value changes. That is: When the user changes the main category (say, from «Car» to «Agricultural Vehicle»), or when the user goes to another record. This can easily be handled with Script Triggers. In my case «onObjectSave_MainCategoryField» and «onRecordLoad_myTable» are doing that job. Both script triggers call a script that updates the global field in the value list table (see picture).

Hope this makes sense :-)

 

This is more a hack than a solution, and I am sure there is a more elegant solution. Also, it would be nice to be able to sort the value list in a different way than the A-Z FileMaker sort order.

So, if anyone has an idea to make this work without script triggers, that would be way cool.

Thanks,

Gary

 

Update global field in value list.jpg

Link to comment
Share on other sites

This topic is 2036 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.