There are several ways to automate this. The details depend on how your database is set up.
If hosted by Server, a server schedule could run a script on a regular basis that checks to see if a report should be emailed and emails it via an SMTP email client.
A similar script could be run each time the file is opened that checks the current date and/or the records to make the same determination and send out the email when needed.
The report can be saved as a PDF and then the PDF can be attached to an email and sent out to the appropriate recipients. All of which can be automated.
How do I get the script to run once per month, say on the 1st of the month? I am running filemaker pro on a dedicated PC, but I am not running the server version.
I've got it configured so the script generates the report, uses SMTP to send it as an email. All good.
From server, you could schedule the script to run once a day. The script would check the date and end without doing anything except on the first day of the month.
Without server, it's less precise as you might not open the file on the first day of the month. You can use a similar script, but you may want to add a table where you log each time an expense report is sent. The script can compare the date the report was last sent against the current date to determine whether to send out the report or to exit.
The file is constantly open. It is running on Filemaker Pro on a mac mini.
The script works perfectly, but I'd like to automate it, so it fires once per month. I guess a script trigger won't fire from Filemaker web access. Is there a way to specify that the script should fire on a particular schedule?
There are two options you can try.
1) Install OnTimer can run a script every so many seconds. You could put 24 hours worth of seconds into this setting to have your script run once a day--and your script, as described previously, exits every day but once each month.
2) You can add a second file to your system. This second, "robot" file has no data and no layouts. It has just one script:
Perform Script [Specify script in your current file for creating/sending the report]
In file OPtions set up this file to run the above script each time the file is opened.
Then use a system level scheduler to open this file on a regularly scheduled interval such as once a month.
On a windows system, you can use Windows Scheduled Tasks for this.
The file opens, runs the script in your main file and then closes.
I understand that Mac systems have the same capability (Cronos?), but am not a mac user and can't give you the details.
I created an applescript to run the script:
tell application "Filemaker Pro"
do script Filemaker script "scriptname"
I then used cronnix (free) to schedule a recurring task to run this script. Note the syntax of the Command must be: