Link to home
Start Free TrialLog in
Avatar of Hiroyuki Tamura
Hiroyuki TamuraFlag for United States of America

asked on

email automatically

hi i need to email all employee daily report to my boss from filemaker database on certain time automatically with instat web.
is it possible?
Avatar of billmercer
billmercer

You can do this fairly easily with FileMaker, it doesn't matter whether you're using instant web publishing or not. There are three things you need to do. First, generating the report as a file, second, sending the file as an email, and third, scheduling this to happen at certain times.

The first part is probably the easiest. Simply create a script that will run the report and either export the set of records to a file, or if you want a formatted report, print to a PDF using a freeware PDF generating utility like PDFCreator (http://sourceforge.net/projects/pdfcreator) or the inexpensive Acrobat alternative NitroPDF (www.nitropdf.com). In either case, you simply generate the file with a known name and location which can be referenced in the second part.  

To email the file, FileMaker has a built-in Send Mail script step, but this works with your default mail client, and usually requires some user interaction to send the message, so that's probably not a good option here. For more flexible emailing from FileMaker, you can use the SMTPit plugin. I've tried it and it works pretty well.
http://www.cnsplug-ins.com/products.htm?product=SMTPit%20Pro 

You can also do the same thing without a plugin by creating an operating system script (applescript, vbscript) to send the email, and using FileMaker's Send Event script step to execute the external script. Let me know if you would like an example of such a script. You can also use a command-line email program. Do a google search for "command line email" and you'll get many links.

For scheduling the process to run at a specific time, you have three options. First, you can set up a script in your database with an endless loop that runs continually, testing the system time on a regular basis and calling a subscript when the time is near a certain value. That's easy to set up, but it will keep the FileMaker user interface tied up running the script all the time. This isn't necessarily a problem.

Second, you can use your operating systems' built-in scheduling facility (cron, Windows scheduler service, etc.) to launch a separate FileMaker database. In this separate file, you only have a simple script which runs when the file is opened. This script calls your report emailing script from the main database, then closes itself. This approach is pretty easy to set up, works very well, and is completely free. I can provide an example file for this as well if you're interested.

The third option is to use a third-party plugin such as the Troi Activator, which has lots of options for running scripts automatically, including scheduling and remote activation.
http://www.troi.com/software/activatordetails.html

Here's another company that has two products you might find helpful, one for controlling printer output, the other an email/sms utility.
http://www.myfmbutler.com/ 

Avatar of Hiroyuki Tamura

ASKER

Thank you, billmercer!
The first part, how would I create and export the set of the record. do you have any example?
This is a simple 3-step script. The first step is to find the set of records, using the Perform Find script step:
Insert a Perform Find script step.
Check the Specify Find Requests option
Specify the fields and values you want to include in your export.

Second, use the Sort Records script step to sort the records into the desired order:
Insert a Sort Records script step.
Check the Specify Sort Order and set up your sort as you would normally.
Check the Perform Without Dialog box to bypass the user prompt so that the script will run without pausing.

Third, use the Export Records script step to export the sorted set of records to a file:
Insert an Export Records script step.
Check the Specify Output File box and enter a specific filename and type of file (an HTML or Tab delimited text would probably be the best formats for this, because they can be easily viewed in a browser, copied and pasted into Excel, and so forth.)
Check the Specify Export Order box, and choose which fields should be included in the export and what order they should be in.
Then check the Perform Without Dialog box, which will prevent any user prompts from appearing so the whole export runs without pausing.

The script will look something like this when finished
  Perform Find [Restore]
  Sort Records[Restore; No dialog]
  Export Records[No dialog; "MyOutput.Tab"]
You can insert these steps in an existing script, or make it a subscript.
 
Also, just as a reminder, you've got an open question here...
https://www.experts-exchange.com/questions/21524235/get-file-path-and-show-image.html
You might want to revisit it and provide more feedback if you're not
happy with the answers.
thank you, billmercer!
how do i find today's record?
could you give me a script?
I assume you already have a field to keep track of the date the record was created.

If you need to do a find based on a variable, such as today's date, you need a few more steps.
This script mimics the steps a person would take in searching for records whose DateCreated field has today's date in it.

  Goto Layout ["Some Layout that has the Table::DateCreated field"]
  Enter Find Mode[]
  Insert Calculated Result [Select; Table::DateCreated; Get(CurrentDate) ]
  Perform Find []

If you're using a flag or other static value to determine which records are today's, it's even easier. A simple find based on a static value will just look like this...

  Perform Find [Restore]
thank you, billmercer!
are there any way to export portal?
You can't export a portal directly, but you can turn the values in a portal into a found set of records by using the Goto Related Record script step. Specify the same relationship that's used to display the values in the portal, and use the option to only show related records. This will very quickly produce a found set of records corresponding to what's shown in the portal, which you can then export.
> Second, you can use your operating systems' built-in scheduling facility
does this have mac?
Mac OS X has the cron utility which can be used to schedule events.
You create a text file called crontab and enter the commands you want to run at certain times according to a special syntax. It's a very simple but powerful way of scheduling events.
Here's a reference
http://clc.its.psu.edu/Labs/Mac/Resources/authdoc/cron.aspx 

Do a Google search for crontab and you will find numerous references.
can i put all table value into one record and email this record?
what kind of script do i need to put all records into one record?
ASKER CERTIFIED SOLUTION
Avatar of billmercer
billmercer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you, billmercer!
i just can export last record.
do you know what's wrong with it?
i made a field and set it as global text in database configuration.
is it OK? or is there any way to set a field as global text with script?
oh, i forgot to add "globaltext &" in setfield.
now it's working. thank you, billmercer!
i have two question.

if there is no record after searching, always give me popup window, ask "there is no record. continue? or cancel"?.

is there any way to prevent from getting popup window? because i need to run the script everyday automatically.

if i don't want to send email after searching no record, what script should i put?
i'm trying to use Activator Plug-in to execute script automatically.
but when i see sample script, i can't understand how to express the time.
why 730485 = Dec 31st, 2000? how do they calculate?
if i want ot triger Sep 14th 05, what's the number?
can this plugin triger everyday?
thanks, billmercer!