Optional Find Script (Server mode)

(or “Advanced Find Script”):

  • Optional for Server-Powered calendars (Client-Side Scripting or Server-Side Async)
    • Runs on the server, after the events are found for display, and any url filters are applied.
    • Can perform a new find, or modify the found set of records that have already been found by using constrain or expand found set.
    • Can work in conjunction with a url string to perform an advanced find based on client-side criteria.
  • Ignored for Standalone calendars

Please note: since this script runs on the server, it isn’t aware of any activity or settings on the client, such as the current record, or global variables. For more information, see FileMaker’s article on Server side scripting.

This script is entirely optional, since URL filters can handle most of what you’ll need to filter events on your calendar. However it can be very powerful when your search needs get complicated. Here’s how it works.

  1. Set the Advanced Find script in the Data Source in soSIMPLE Calendar Settings.
  2. You can pass a variable to this script by adding a parameter string to your url. Add “&find_parameter=” to your url. Whatever follows this string will be first line returned with get(scriptparameter) in this script.
  3. Your calendar will render as usual, and the events will be queried from the server. Any url filters you’ve added to the query string will be parsed.
  4. Before the events are returned for display on the calendar, the Optional Find Script will run on the server. This means you won’t see it run – the server runs it invisibly before the events are returned.
    • When this script runs, you will be in the context of your events data table as defined in your Data Source.
    • The found set at the beginning of the script will be whatever would have shown on the calendar if you didn’t use this script.
      • You can choose to create a new search, or you can constrain the current found set.
    • getvalue parametersThe following lines are passed as a multi-line script parameter. You’ll need to parse them out with the getvalue() function.
      • Value 1: find_parameter from URL
      • Value 2: date range from (automatically determined by dates being shown on the calendar)
      • Value 3: date range to
      • Value 4: resource being filtered (“unit” in query parameter)
      • Value 5: action script that will be run
      • Value 6: event id of a specific event being queried (“queryid” query parameter)
  5. Perform any type of search you’d like at this point.
    • Always include the date range in your search, or you’ll return results from your entire database, with no regard to the currently viewed timeframe. One the features of server-powered soSIMPLE calendars is that they only request events they need to show for the current timeframe.
    • Keep in mind that global fields and variables set in FileMaker Pro will NOT be available to this script, since the script is run on the server. You’d have to pass any necessary variables in the &find_parameter string.
  6. The found set will be shown on the calendar.