Portage Bay
Portage Bay

Modular Date Range Chooser

Are you looking for a reusable tool to be integrated with your FileMaker solution that provides an easy to use date range chooser popup window? Look no further! Portage Bay has created the Modular Date Range Chooser which can easily be added to your solution, either by copying and pasting the components into your existing solution, or linking the file as an external widget file. I am currently in the process of uploading this to modularfilemaker.org so it will be available to any FileMaker developer.

The benefit of using the file as a widget is that it can be linked with any FileMaker solution. A card window widget is a very DRY (don’t repeat yourself) approach to coding, so you can easily integrate the same feature with multiple solutions without having to recreate it each time. So for example, if you have a CRM and wish to use the tool to select a date range for generating reports, you can link the widget with your CRM. If you also have a database used to manage sales and products, you can link the widget to this file also, providing the capability to select a date range. It takes just a few minutes to link the widget to an existing file and then can be reused time after time. If you choose to use the copy and paste method, the date range chooser functionality will be integrated into your existing solution, but there is a higher risk of missing a step, breaking something when doing so, or having trouble upgrading to a newer version of the date range chooser later.

About the Technique

The minimum version for the file is 16, as this technique does use JSON in the required scripts. The file uses the Universal Touch theme, standardizing the look and feel and making it easy to match any existing solution. It also ensures the buttons and layout size can be easily used in an iOS or web solution.

Script Parameters

The parameters are all optional, but we’ve added them to give you more options to control the size and location of the window. All parameters are passed as a JSON object. If you are unfamiliar with JSON, please see the “DateRange_Example” script for an example of how to format it. Below are the three optional parameters. If no parameters are passed, the window will default to a Card window centered within the parent window.

  • Left: Number of pixels window should appear from the left edge of the parent window.

  • Top: Number of pixels window should appear from top left edge of the parent window.

  • Window Type: Either “Card” or “Dialog” (a Card window is stationary, automatically dims the background of the parent background and cannot be moved, whereas a Dialog window can be moved although the background will not be dimmed).

Preset Date Ranges

After the script is called to open the Date Range Chooser window, the script will pause, allowing the user to interact with the chooser, entering either a custom date range or selecting one of the preset date ranges. The preset date ranges are as follows:

  • Today

  • Yesterday

  • Last Seven (last seven consecutive days, inclusive of today)

  • Last Week (last full week Monday through Sunday prior to today)

  • Month to Date (first day of the current month throughout today)

  • This Month (first day to last day of current month)

  • Previous Month (first day to last day of prior month)

  • Year to Date (first day of current year through today)

  • This Year (first day to last day of current year)

  • Previous Year (first day to last day of prior year)

Error Validation

If there are any errors such as an invalid date range, missing end date, or missing start date, error text will display in red and you will be unable to continue the date selection process without correcting the date range. The cancel button will of course still be available.

Script Results

Once a valid date range is chosen and the OK button is clicked, the script will return a result formatted as JSON that contains both the start date and end date. You can parse these results in your calling script and then do whatever you like with those dates.

How to Integrate

Follow the instructions in the “DateRange README” script available in the demo file. This includes instructions on both incorporating the widget into a solution or linking it to an existing solution as a widget file.

If you have any questions or would like assistance integrating the Modular Date Range Chooser into your solution, please contact us.

~ Kate Waldhauser