2 Replies Latest reply on Nov 27, 2008 10:00 AM by Martin1

    Saving multiple records as Individual PDF's



      Saving multiple records as Individual PDF's




      I have been trying for sometime now to write a script which allows me to e-mail individual schedules as pdf's for multiple records in a found set. I keep coming up against the same problem in that I can only get filemaker to save all of the records in one pdf document.


      What I want to do is as follows :


      1. Import data from excel spreadsheets provided by our clients.

      2. Save each individual record as a PDF in a specific file without having to go into each record individually, create a save file name and then save it.

      3. Then create a seperate e-mail per pdf to send back to specific employees at our clients.


      If I can automate this process with a scrip it will save our administration team a considerable amount of time. Any help greatfully appreciated.


      Many thanks






        • 1. Re: Saving multiple records as Individual PDF's

          Hi Martin


          You can run a script that will do this for you, but first I just want to check if you store the email address the report is going to in the table of data you are working with, or how you know who the report goes to?


          Assuming there is a field in the table you are working on called _EmailTo here is how you should setup your script to generate a PDF and email to as an attachment.


          You do not mention where you want the report to be stored after the process is complete, on a hard disk, on a hard disk and attached to the record or stored in a container.


          For the purpose of this script I assume there is a folder in the same location as the database file called Report, and the PDF's generated will be placed in there with the name set to the _UniqueID field which is in the main table and set to Auto-enter Serial so each record has a unique number. This can be modified to be any field or calculation you require.



            Go to Layout [ “ReportLayout” (TABLE) ] 

            Import Records [ ] 

            # Process your imported data if required. 

            Go to Record/Request/Page [ First ] 


              Set Variable [ $FilePath; Value:"File:Report/" & _UniqueID & ".pdf" ] 

              Save Records as PDF [ File Name: “$FilePath”; Current record ] 

              Send Mail [ To: TABLE::_EmailTo ; Subject: "Report"; Message: ""; Attachment: “$FilePath” ] 

              #Attach to container if required

              Go to Layout [ “LayoutWithReportContainer” (TABLE) ] 

               Insert File [ Blank9::container; “$FilePath” ] and you could select [ Reference Only ]

              Go to Layout [ “ReportLayout” (TABLE) ]     

              #END of Attach

              Go to Record/Request/Page [ Next; Exit after last ] 

            End Loop 



          When setting up the Save as PDF script step make sure to select "Specify Options" and change the "Save" option to "Current Record" this will then only PDF the record the script is currently in instead of the whole found set.


          Also if you do decide to insert the file into a container on that record, either as a reference or whole file, you need to go to a layout based on that table that has the container field on, otherwise FileMaker cannot insert the file. 


          I hope this helps and do let me know if anything is unclear.


          • 2. Re: Saving multiple records as Individual PDF's



            thanks for the reply, it looks as though there might be light at the end of the tunnel !!!


            In all circumstances there will be an e-mail address provided with the data we import and utilse to issue the schedule. The only caviat is one of our clients likes all their schedules on one e-mail but in seperate pdf's.


            Basically in terms of schedule storage we have a specific folder for each one of our clients named [client name] Schedules and the format for each schedule stored is [Name] [Unique Ref No].PDF in that folder. Each folder is a sub-folder of the clients main folder which is utilised for general correspondence etc. There is no need to utilise any container fields or even link the schedule back to Filemaker as the information can either be obtained directly from the imported information stored on Filemaker or from the saved pdf.


            At the moment I can process the individual records in the found set on the basis of saving each record as a pdf and then generating an e-mail with the clients details in but we have to physically find the clients file, create the file name and then attach it to the e-mail. When clients are sending us about 250 a week you can understand my dilemma ?


            Am I correct in assuming that the script you have provided will import the records, say 50, then select each individually and save them as a pdf. At this stage it looks as though they would store in a container field. Can they be saved in the format I mentioned above ?


            Then I assume an e-mail will be generated and the pdf attached an sent ?


            Subject to the schedule being saved in the pocation I have detailed this looks as though it may work. If you can advise on this I will try it out and get back to you.


            Many thanks for your assistance