Brian Dunning's FileMaker Custom Functions

JSONforLayoutFields ( Layout )

Builds a JSON object for the non empty fields on the specified layout

  Be the first to rate this function Log in to vote

Neil Manchester   Neil Manchester - Show more from this author
NDMW

Share on Facebook Share on Twitter

  Sample input:
JSONforLayoutFields ("Client")
  Sample output:
{

"FirstName": "Jeremy",

"LastName": "Brown",

"Address": "Somewhere in Orlando",

"ReasonMoved" : "Done with winters"

}

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

This function uses a While loop to build a JSON object containing the field names and values on the specified layout.

 

Comments

Jesus Sanchez   Jesus Sanchez, dbFile Desarrollos
May 4, 2020
Great function Neil, just a comment, as you have already evaluated _fieldEmpty , you can substitute this part:

_json = If ( IsEmpty ( GetField ( GetValue ( _fieldNames ; _n ) ) )

with:

_json = If ( _fieldEmpty; _json; JSONSetElement.....

Thanks for function.
 
Neil Manchester   Neil Manchester, NDMW
May 4, 2020
Hi Jesus. Great spot! I've updated the CF. Many thanks
 

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: