Set Fields With Values

A simple re-usable script for performing the everyday task of setField with optional actions such as refresh and go to object. Multiple setField actions can be performed. It is particular useful as the target of a script trigger.

The setFieldsWithValues script can be used as is on any layout in any file. The script is driven by the script parameter supplied.

Rather than creating many similar scripts to perform similar tasks on different layouts here a single script script is re-useable anywhere by supplying specific instructions in the script parameter when the script is run. Script parameters can be created, edited and saved as snippets in a text editor. The intention is to save development time and to simplify a FileMaker solution by using abstraction.

Basic usage is to set a field with a value, or with no value to clear the field. Many fields may be set with many values at the same time. In addition the set field actions may be preceded by a confirmation dialog and succeeded by various everyday actions such as commit record, refresh widow or portal or object and go to object.

I find this script saves me writing lots of small layout specific scripts where a single step button will not suffice or where i would like to add a single step action to a scriptTrigger. Among many other uses I find this script very useful with Selector Connector for setting a bunch of key fields onRecordLoad.

The sample file with simple usage examples is available here on GitHub

If you are not familiar with GitHub: how to download the zip file from GitHub

Dependencies

The script requires 3 custom functions: CustomList(), #() and #Assign() so it is not strictly modular however it is offered here in case anyone else finds it useful. One day, when I have time, I may see if the script can be made more modular by scripting those functions. Suggestions for this are welcome.

Important: if you want to install this module you must install the required custom functions  before installing the module.

Example Script Parameters:

These examples are meant to illustrate the kind of things that can be done using this script – they are not meant to be used as shown.

Example 1.

#("targetField1" ; GetFieldName ( SELECTOR::ID_ELEMENT ) )
& #("value1"; Element::id )

Example 2.


#("targetField1" ; GetFieldName ( SELECTOR::ID_FUNDAMENTAL ) )
& #("value1"; Fundamental::id )
////////////////////////////////////////////
// Set/reset defaults
////////////////////////////////////////////
// Select first image
& #("targetField3" ; GetFieldName ( SELECTOR::ID_IMAGE ) )
& #("value3"; Fundamental_ImageFolder__Jn___Image::id )
// Clear the movie selector
& #("targetField4" ; GetFieldName ( SELECTOR::ID_MOVIE ) )
// Clear the audio-file selector
& #("targetField5" ; GetFieldName ( SELECTOR::ID_AUDIOFILE ) )
// Clear Web-links
& #("targetField6" ; GetFieldName ( SELECTOR::ID_WEBLINK ) )
// clear the Doc Selector
& #("targetField7" ; GetFieldName ( SELECTOR::ID_DOC ) )
////////////////////////////////////////////
// load default folders
////////////////////////////////////////////
// Load the top level Image Folder
& #("targetField8" ; GetFieldName ( SELECTOR::ID_IMAGEFOLDER ) )
& #("value8";
ExecuteSQL (
"SELECT " & SQLFieldName ( ImageFolder::id ) &
" FROM " & SQLTableName ( ImageFolder::id ) &
" WHERE " & SQLFieldName ( ImageFolder::id_fundamental ) & " = ?
AND " & SQLFieldName ( ImageFolder::isTopFolder ) & " = 1";
"" ; "" ; Fundamental::id
)
)
// load the Top Movie Folder
& #("targetField9" ; GetFieldName ( SELECTOR::ID_MOVIEFOLDER ) )
& #("value9";
ExecuteSQL (
"SELECT " & SQLFieldName ( MovieFolder::id ) &
" FROM " & SQLTableName ( MovieFolder::id ) &
" WHERE " & SQLFieldName ( MovieFolder::id_fundamental ) & " = ?
AND " & SQLFieldName ( MovieFolder::isTopFolder ) & " = 1";
"" ; "" ; Fundamental::id
)
)
// load the Top Audio-File Folder
& #("targetField10" ; GetFieldName ( SELECTOR::ID_AUDIOFOLDER ) )
& #("value10";
ExecuteSQL (
"SELECT " & SQLFieldName ( AudioFolder::id ) &
" FROM " & SQLTableName ( AudioFolder::id ) &
" WHERE " & SQLFieldName ( AudioFolder::id_fundamental ) & " = ?
AND " & SQLFieldName ( AudioFolder::isTopFolder ) & " = 1";
"" ; "" ; Fundamental::id
)
)
// Load the Top Doc Folder
& #("targetField11" ; GetFieldName ( SELECTOR::ID_DOCFOLDER ) )
& #("value11";
ExecuteSQL (
"SELECT " & SQLFieldName ( DocFolder::id ) &
" FROM " & SQLTableName ( DocFolder::id ) &
" WHERE " &SQLFieldName ( DocFolder::id_fundamental ) & " = ?
AND " & SQLFieldName ( DocFolder::isTopFolder ) & " = 1";
"" ; "" ; Fundamental::id
)
)
& #("commit"; True )