Custom Dynamic Value Lists

Within the realm of FileMaker development, there are a number of key techniques which allow you to do the types of things you'd normally expect in any development environment. Many of these have been around for many years. In this case, this one, a decade. The unfortunate thing is that some of these obscure methods and techniques just aren't that easy to replicate from memory. Some are hidden in the corners of FileMaker development because they feel like they're "hacks". But, at least they get the job done.

For FileMaker, the fact that you can derive a value list from a related set of values is extremely valuable. If you have a class of cars and you need a value list with a sublist of models, then getting a related value list is really easy and useful.

But, what if you need a bit more control? You want to specify the exact values used. They need to be custom and you want to include calculated values which are dynamic in nature. You also want them in some type of fixed order and separated with dividers. Doing this is "almost" impossible unless you know the special "hacks" which allow you to achieve the desired result. This video and technique file will show you how to take full control of value lists and use Custom Dynamic Value Lists in the exact way you think you should be able to!

AttachmentSize
CustomDynamicValueLists.zip1.59 MB
Tags:

Comments

love the fact that I am still learning new ways to do things...
the reason that the second (or third) field is required for another list is when there is a need for a second value list that is dependant on the values chosen in the first, which your example does not show. There may be a script which runs to pre-collect all the relevant parent values along with (say) a JSON structure of the related child values so that on Modify the first selection box can then select the values for the second

So pick a make of car
Next pick a colour for your car. Each can could have its own names for red for example...

John r

Since we have to create the recID field, I replaced the 3 steps previously used and did this:

Find Matching Records [Replace;Table::recID]

works slick and doesn't rely on the relationship

You could modify the CF so there is an inner while so you don't need to depend on the BOM function, less to copy/paste, although I appreciate you might have it there for other purposes

The null script. If you do an object modify on the selection field and pass the ActiveFieldName to it, you can multi-purpose the script so that if there is a ScriptParameter it will do the Substitute and SetFieldByName there. Saves forgetting to add it as a AutoEnter Calc in the schema which means you don't have to open the Definition Dialog, and makes the field/contorl easier to just copy/paste - all you need to do is modify the list it uses to create the $$VAR

There are often reasons for setting the $$VAR in a script before you even get to the layout, as part of navigation say, as the list may be derived from a query ( either ExecuteSQL or ExecuteDataAPI) so that they can be even more dynamic

John r

Thank you, amazing stuff like usual and we will for sure test and use this.

One of my latest interest is using local variables instead of globals in stuff you wouldn't think to (this also comes from watching your videos 😀 ). I'm not a fan of needing to think of emptying them when their scope are not truly global in your file and you are okay with them being dumped right after being used. We've been implementing ui translations with local merge variables declared in a custom function hidden in a hide condition.

So of course the first thing I tried with this dynamic value list trick is to do the same thing but with a local variable. Not surprisingly, it works perfectly. I wanted to share an interesting behaviour of doing this : for the first time that I've seen, Filemaker is "trapping" the local variable in memory when used to build a value list.

What I mean is that, taking your example file, I change all $$Value.List to $Value.List, click on the popup menu once, then I can do whatever I want, change records, create a layout, go to layout mode, remove the triggers, go back to browse, try the menu again. It will keep working, the menu is perfectly populated. $Value.List will never appear in the Current tab of the data viewer, but will show you the list if you call it in Watch. This was never true for any other tests we've done with them.

Even more interesting, if you start a script, it disappears from the data viewer, and if you use it in the script, it will be empty. But as soon as the script ends, lo and behold, $Value.List is back with its value!

I'm really curious about what's really happening! I just love "playing" with Filemaker like that. Continue your good work!

Hi Mat,
I don't really know why, I've copied your technic and it works. Except sorting with unicode.
The global variable has a text value list, but when used as value list on the layout it is sorted by language and not like the values into the global variable.
I don't know where I'm wrong
Kind regards
Antoine

Hi Mat,
I really enjoy your videos! I'm really having a hard time trying to filter a value list that is based upon a date field in a table1. I get a list of the dates in a field in table2 and everything works, except, as time goes on, the list gets really really long. Is there a way to filter the list based upon a field called Assignment Date so that the value list only shows dates within the current year of the Assignment Date field. FYI, my year is from 8/1 - 7/31.

Thanks in advance!
bdembar

Drums

Hi Matt - Thank you for the amazing videos and solutions! Much appreciated. For this custom function to work, does it work only on versions lower than FM18 as the first IF statement says? I also noticed that some of the JSON elements are not part of my FM solution.

Thanks,
Ron