Copying Value Lists in FileMaker
Updated: Apr 6, 2022
There may come a time when you need to copy a Value List from a database so that you can use it in another, and since FileMaker haven't yet included this functionality outside of the DDR, I've scripted as much of it as I can for you.
To start off create the script I've outlined below in a FileMaker db (this could be in the target db but it could also run in the donor db) then make sure that both the donor db and the db running the script are open.
1. Open the Data Viewer and make sure that you're monitoring $$ValueListFinal
2. Run the script I've outlined below.
3. Copy the value of $$ValueListFinal into a text editor
4. Copy the values into your chosen DB (the value lists are separated by ==== and carriage returns plus the top line is the name of the value list itself).
NB Why do this instead of using the DDR? The Database Design Report is all well and good but it displays value lists as lines of data with the value list items separated by commas not carriage returns which are not very handy when it comes to copying into your target value list. This is a very cut down script and, if you need to use it often, could certainly do with a dialogue asking the user to locate the target file.
Show Custom Dialog [ Title: "Warning"; Message: "Make sure that the data viewer is open and $$ValueListFinal is being monitored."; Buttons: “OK” ]
#Reset the final value list breakdown.
Set Variable [ $$ValueListFinal; Value:"" ]
#Determine how many value lists there are in the target DB.
Set Variable [ $ValueListNames; Value:ValueListNames ( "TARGET DATABASE NAME HERE.fp7" )
Set Variable [ $ValueListCount; Value:ValueCount ( $ValueListNames ) ]
#Loop through the value lists.
Set Variable [ $Counter; Value:$Counter + 1 ]
Set Variable [ $$ValueListFinal; Value:GetValue ( $ValueListNames ; $Counter ) &¶&
ValueListItems ( "TARGET DATABASE NAME HERE.fp7" ; GetValue ( $ValueListNames ; $Counter ) ) &¶&
Exit Loop If [ $Counter ≥ $ValueListCount ]
If you notice anything wrong with this blog, think that you can do it better or just want to discuss it, then please get in touch.