Are you generating a PDF of the report and want to send it as an attachment?
The first part of that process, using Save As PDF to generate the PDF is described here: Found Sets to PDF with unique file names
Yes--and I'm able to generate the report, but it has all the departments and all the users. I want the script to create a report for just that department and all of its users, send the email with pdf attached, then repeat for each department.
Do you have a Staff table in your database such that when a user logs in it asscoiates their login name with their department in the database? You can have a script that runs on startup that find a related Staff record in the database which contains a field for their department. Then, when the user runs a report you can contrain the found set to only find records that have the related value of the department.
Without a detailed picture of how you have set up your tables/relationships we can only offer general information. There are two basic approaches:
- Perform a find for just the records you want in your report. Such finds may be scripted.
- Use relationships to limit the data used in the report solely to those linked to the current record on your layout.