From Dwayne Wright PMP
Certified FileMaker Developer
Please Note: If you are viewing this page in a news feeder, the images may get munged up a bit. For the best experience, please visit the journal directly by clicking (here).
Many developers distribute demo or prototype versions of their solutions. There are a number of reasons why a developer may want to limit the shelf life of these files. Generally this is because they want the latest version of these files in front of potential customers.
In this article, we are showing four possible ways to go about implementing a shelf life feature. These all include the setup of a startup script when a FileMaker file is opened. These techniques are NOT features you would want to utilize as security. They can be defeated rather easily and proper FileMaker security always includes the Manage Security menu command and associated dialog boxes. Instead, you would want to implement these features to pursade the customer to purchase or at least download a later version of the demo.
Under the File menu, you can see a menu command called File Options. From here, you can assign a script to perform on opening or closing that particular file. This can be used to setup the file properly or close it properly in regards to the way you want the data organized.
PREVENT OPEN BASED ON RECORD COUNT
This example shows, download by clicking (here), how a file can shutdown as determined by a particular record count in a table. Our default number of records in this example file is set to 10. We have provided a few buttons ( red in color ) that will help in testing how the method works. One will create enough records to exceed the allowed number. The other will bring the files record count back down to one record. FYI... We have also built in a backdoor so that we can open the file even if the date range has passed.
Key to this functionality is the Get(TotalRecordCount) function. This function will return the sum count of all the records in the current FileMaker table as viewed by the foremost layout window. The current table will refer to the source table that is attached to the table occurrence in the current layout. The calculation will need to be unstored in order to be accurate when viewed on the layout. It will count the current users uncommitted records as well as the records that are in the index.
PREVENTION BASED ON TIMES OPENED
This example shows, download by clicking (here), how a file can automatically quit, if the file has been opened a determined number of times. This is done via a counter (in this case via a global field) and tested by a startup script. You will need to make sure the global field is empty when you distribute this solution or the user will have less than the optimum number of launches.
FYI ... I used a global field and this would not work in a multiple user setting. This is because a global field in multiple user settings does not retain changes to its value during a user session. This only happens in single user modes and most FileMaker demos are design for single user only. You can easily tweak this example to be multiple user savvy by using a regular field instead of a global field. You just need to make sure each user is on the same record at startup for the counter to increment correctly.
Back to the example, we have set the number of times the file can open to 10 occurrences after it is first opened. We have provided a few buttons ( red in color ) that will allow you to reset the number and test the opening script process.
FYI... We have also built in a backdoor so that we can open the file even if the date range has passed. This is done by holding down a modifier key on the keyboard as the file opens. This uses the Get(ModifierKey) function, which will return a number result depending on the key held down. If more than one key is held down, the function results the sum value of each key. The individual values for each key is Shift = 1, Caps Lock = 2, Ctrl (Windows) and Control (Mac OS) = 4, Alt (Windows) and Option (Mac OS) = 8 and Command (Mac OS) = 16. If a user was holding down the shift and the Ctrl keys, the function would return 5. This is the sum of the two key ( Shift = 1 ) + ( Ctrl = 4).
PREVENT OPEN BASED UPON A DATE
This example shows, download by clicking (here), how a file can automatically quit at a predefined date. We have also built in a backdoor so that we can open the file even if the date range has passed. By default, we have set the turn off date to be 1/23/2012. We have included a button that will set the turn off date to one day minus today ( yesterday ). Click the button and then click the button below it to test.
We have also used the Get(ActiveModifierKeys) function to build in a back door that will bypass the deactivation script. To test, make sure the Turn Off Date field is set for a date before today. Hold down the shift key and click the Auto deactivate button.
NOTE: We have hard coded the name of the file being closed and FileMaker currently does not have another option for us. So if your file has a different name, you will need to update the script accordingly.
PREVENT OPEN BASED UPON A NUMBER OF DAYS AFTER INITIATION DATE
This example shows, download by clicking (here), how a file can automatically quit a determined number of days after the file was first opened. This method assumes the solution is a single user solution and not networked. This is the common setup when you deliver a demo of a product and you want to set a date when it expires.
I did not wire up the time bomb script as the startup script for this example. In normal practice, you would. I just didn’t want to bewilder users with a time bomb on an example file. So I added a button to test the script. So you can experiment with different settings and click the test button. By all means, you will not want to allow users to see or edit the key fields for the operation. I do that here for example purposes.
The actual startup script will see if the Date First Opened field has data. If it doesn’t, it adds the current date into the field and stops the rest of the script. If the Date First Opened field does have data, it evaluates if the Turn Off Date is less than the current date. If so, it closes the file after showing you a message.
Although the method in this example would not work in a hosted environment, it would take a few tweaks to make it that way. In a case like this, you would probably want the time bomb to be linked to a user account. You would like use a user account table to determine the date first opened and refer to it via a relationship.
More info about the author and FileMaker in general, contact me at firstname.lastname@example.org.
© 2011 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.