Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

dynamic sorting

Featured Replies

I'm trying to make an "Ultimate" Filemaker find and sort subroutine, where I just pass some lists to the subroutine, and it returns the found fields, sorted in the order I requested. I don't want to bore you w/the entire script, so I'll just ask about the sort part, which is where I'm getting stuck.

I know FMP likes to sort in this syntax:

sort by {field "State", field "Date"} in order {ascending, descending}

So I'm trying to write a script to build that sort from 2 lists. Here's how far I've gotten, but i'm stuck on how to build a list that looks like {field "abc", field "xyz"} .

Can someone help?

TIA.

Dan

set theFieldsToSortList to {"State", "Date"}

set theSortOrderList to {"ascending", "descending"}

tell application "FileMaker Pro"

tell database "xyz"

set SortFieldList to {}

set SortOrderList to {}

repeat with i from 1 to the length of theFieldsToSortList

set thisSortField to item i of theFieldsToSortList

set thisSortOrder to item i of theSortOrderList

set SortFieldList to SortFieldList & field & thisSortItem

set SortOrderList to SortOrderList & thisSortOrder

end repeat

sort bySortFieldList in order SortOrderList

end tell

end tell

Use this syntax:


set fieldlist to {"LastName", "FirstName", "PhoneNo"}

set orderlist to {"ascending", "ascending", "descending"}

set sortfieldlist to {}

set sortorderlist to {}

tell application "FileMaker Pro"

repeat with i from 1 to (count fieldlist)

set itemsortorder to ascending

if (item i of orderlist) = "descending" then set itemsortorder to descending

set sortfieldlist to sortfieldlist & {a reference to field (item i of fieldlist)}

set sortorderlist to sortorderlist & itemsortorder

end repeat

sort by sortfieldlist in order sortorderlist

end tell


  • 1 month later...
  • Author

Thanks Bob! That SO did it! I've been using this subroutine for a while now and it's been great... Until...

I just loaded OS X 10.2 on my computer, and now Filemaker crashes when I invoke this sort subroutine, with the error: The Connection is invalid. I even made a dummy database to test it, and it crashed the dummy too. I'm using FMP 5.5v2. Any ideas?

  • Author

Never mind. I figured it out myself. I had

Tell app "Filemaker"

tell database theDatabase

-- find code goes here

end tell

-- sort code goes here

end tell

for some reason this worked great until 10.2. Now it requires

Tell app "Filemaker"

tell database theDatabase

-- find code goes here

-- sort code goes here

end tell

end tell

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.