All field comments are to be formatted as valid JSON. Even if the only supplied key/value pair is a comment itself, the advantages of the structure provided by JSON allows for tightly coupled metadata specific to the field. These include, but are not limited to.
Field comment metadata can easily be retrieved for any given field using the following native function.
FieldComment ( fileName ; fieldName )
When combined with functions like
FieldNames ( fileName ; layoutName )
and/or
ExecuteSQL ( sqlQuery ; fieldSeparator ; rowSeparator { ; arguments... } )
Using the available internal SQL system objects (see page 35 of the Claris/FileMaker SQL-Reference.pdf) we have something like the following for a list of all fields within a given table.
Example custom function:
TableFields ( listOfFields )
ExecuteSQL ( "SELECT TableName + '::' + FieldName FROM FileMaker_Fields WHERE TableName='" & table & "'" ; "" ; "" )
JSON can be extracted and modified in a wide variety of ways within Claris/FileMaker.
Given that JSON is not the native structure for script variables, it's possible to use a simple custom function which will convert Claris/FileMaker's imposed JSON formatting structure via JSONFormatElements ( json )
into a valid Let()
function. See JSONLetify (special nod to JavaScript's JSON.stringify() method)
Here's an example of a JSON object which could be used as a field comment.
{
"comment" : "This is a comment about this field.",
"labels" :
{
"$@field_label_merge_variable" :
{
"de" : "Feld",
"en" : "Field",
"es" : "Campo"
}
},
"options" :
{
"de" : [ "Eins", "Zwei", "Drei", "Vier" ],
"en" : [ "One", "Two", "Three", "Four" ],
"es" : [ "Uno", "Dos", "Tres", "Cuatro" ]
},
"twilio_api" :
{
"number" : "800-555-1212",
"prefix" : "[Notice]"
}
}