Brian Dunning's FileMaker Custom Functions

SortRecordsByJSON_AppleScript ( sort_array )

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

  Average rating: 5.0 (1 vote) 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:

[
{
"field" : "tablename:: field1",
"order" : "ascending"
},
{
"field" : "tablename:: field1",
"order" : "descending"
}
]


You may use following calculation to generate the JSON:


JSONSetElement ( "[]" ;
[ "[0]field" ; GetFieldName ( tablename::field1 ) ; JSONString ] ;
[ "[0]order" ; "ascending" ; JSONString ] ;
[ "[1]field" ; GetFieldName ( tablename::field2 ) ; JSONString ] ;
[ "[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 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: