Brian Dunning's FileMaker Custom Functions

SQLasJSON ( tablename ; fields ; condition )

Performs SQL query on designated table and returns response from declared fields wrapped as JSON.

  Be the first to rate this function Log in to vote

Jonni™   Jonni™ - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
SQLasJSON ( "myTable" ; "field1, field2, field3" ; "WHERE myField = 'myValue'" )
  Sample output:
{
"data" :
{
"columns" : 3,
"rows" : 2
},
"response" :
[
{
"fieldName1" : "value1",
"fieldName2" : "value2",
"fieldName3" : "value3"
},
{
"fieldName1" : "value1",
"fieldName2" : "value2",
"fieldName3" : "value3"
}
]
}

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This function performs an ExecuteSQL query to the designated table to retrieve values of declared field names. If the condition is passed blank or partial table if SQL conditions are passed in the conditions parameter.

The results is then wrapped into a JSON array where each row is defined as one object consisting of entities where key is defined as the declared field name populated but the returned value.

Additionally row count and field count are returned within the data object.

Requires FileMaker 18 or higher

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: