Brian Dunning's FileMaker Custom Functions

SortRecordsByJSON_AppleScript ( sort_array )

Dynamic sorting for hierarchical field order to create nested subsummaries (macOS only)

  Be the first to rate this function Log in to vote

Thomas Siebert   Thomas Siebert - Show more from this author
http://www.t-seabird.de

Share on Facebook Share on Twitter

  Sample input:
{
"sort" :
[
{
"field" : "tablename::fieldname1",
"order" : "ascending"
},
{
"field" : "tablename::fieldname2",
"order" : "descending"
}
]
}
  Sample output:
sorting of the current layout

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

Dynamic sorting for hierarchical field order to create nested subsummaries.
Use the Scriptstep "perform AppleScript" with the option "Calculated AppleScript".

Deliver an JSON-Array in following form:

{
"sort" :
[
{
"field" : "tablename::fieldname1",
"order" : "ascending"
},
{
"field" : "tablename::fieldname2",
"order" : "descending"
}
]
}


You may use following calculation to generate the JSON:


JSONSetElement ( "{}" ;
[ "sort.[0]field" ; GetFieldName ( tablename::fieldname1 ) ; JSONString ] ;
[ "sort.[0]order" ; "ascending" ; JSONString ] ;
[ "sort.[1]field" ; GetFieldName ( tablename::fieldname2 ) ; JSONString ] ;
[ "sort.[1]order" ; "descending" ; JSONString ]
)

 

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 16 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: