Updating Global fields so that the changes "Stick".
Ever have this happen to you?
You update a copy of your database file on your development machine using FMP or FMP advanced, upload it to FM Server and then start getting lots of complaints from users when the database doesn't function as they expected. You examine the problem and realize that you left data in one or more global fields while working with your file as a single user on your development platform. Now each user encounters unexpected behavior because their client session opens with these left over values. Portals that use a global field to filter records, may show all the "Rhode Island", instead of the default "California" or "All" setting the user expected, for one example. The clients can often set the globals back to the expected values, but then the original values return the next time they quit and log back on to the system.
You could open the file as a single user, fix the values and then upload the fixed copy to your server, but then you have to kick 30 or 40 users off while you do it and you really don't want to trash all the work they've done since the upload either.
Here's another way to permanently change the data stored in global fields without having to upload a new copy of the file to the server.
Create a simple script in the file:
Set Field ["table::field1, "default value1"]
Set Field ["table::field2, "default value2"]
and so forth....
Open server and create a schedule to run this script.
Run the schedule.
Changes made to global fields from a server side script will be retained. Each client that connects to the data base after the schedule has run will see the global field values set by the script.
Disable your schedule, but keep it around for the next time you forget to set your globals correctly. :smileywink:
Note: server side scripts will automatically run scripts set in file options to run when the file is opened and/or closed. To keep these scripts from running, you can add the following if statement at the beginning of the script:
If [Get(currentUser) = "ScheduleName"] /* Make sure that your schedule's name does match any user name */
Exit Script