6 Replies Latest reply on Apr 19, 2015 10:27 AM by otto_m

    E-mail single PDF page to recipient concerned

    otto_m

      Title

      E-mail single PDF page to recipient concerned

      Post

      Hi,

      I cannot figure out how to solve this problem:

      I have a database to assign approx. 180 different courses to some 30 lecturers in a variety of departments.

      The database consists of three tables - COURSE, LECTURER and DEPARTMENTCOURSE and LECTURER share the key LECT (unique four-letter ID of each lecturer), DEPARTMENT and COURSE share the key DEPT (unique three-letter ID of each dept.)

      Each term I repeat the same tedious procedure: saving the assignments for each lecturer to a PDF file, then mailing the PDF individually to each lecturer.

      The pdf is generated in FileMaker' print view consisting of the following parts:

      • Header: "Teaching assignments for <<TERM>> <<YEAR>>"

      • Sub-summary when sorted by LECT - contains the lecturer's full name etc. from LECTURER table

      • Body - contains details from COURSE table, such as number of hours, scheduled weekday etc.

      • Another sub-summary when sorted by LECT - total number of hours and page break after each 1 occurrence

      I have been able to put together a script so I get a nice one-page PDF for each lecturer.

      My question now:

      Is it possible to create a script that sends only the page in question to the lecturer concerned?

      If yes, what do I have to do?

      Thank you very much in advance,

      Otto

        • 1. Re: E-mail single PDF page to recipient concerned
          philmodjunk

          You would need to modify the script to generate a different 1 page pdf for each lecturer in order to attach that file to an email sent to the lecturer.

          • 2. Re: E-mail single PDF page to recipient concerned
            otto_m

            Thank you for your hint.

            However, I cannot figure out how to generate a different 1-page PDF for each lecturer?

            Can you help me with the script?

            Thanks in advance,

            Otto

            • 3. Re: E-mail single PDF page to recipient concerned
              philmodjunk

              You'll need to perform a find for the group of records associated with each lecturer, sort them (so that the sub summary parts are visible and then save the PDF.

              You may need to pull up a list of lecturers and perform a find for each  in a loop that's basically:

              Perform find
              Sort
              Save As PDF

              This thread on scripted find examples may be helpful: Scripted Find Examples

              • 4. Re: E-mail single PDF page to recipient concerned
                otto_m

                Thank you for your hints. 

                The easiest is to perform a manual find using a pop-up menu.

                To send the file, I have gleaned the next steps from one of the FileMaker starter solutions that worked well for a conference:

                Enter Preview Mode

                Adjust Window [Resize to Fit]

                Print Setup [Restore ; No dialog]

                Pause/Resume Script [Indefinitely]

                Set Variable [$$FileName ; "/*COURSE::LECT  & \"_\" & Month ( Get ( CurrentDate ) ) & \"_\" & Day ( Get ( CurrentDate ) ) & \"_\" &Right ( Year ( Get ( CurrentDate ) ) ; 2 ) & \".pdf\”*/“]

                Set Variable [$$FilePath ; Let ( [        MAC = "filemac:" & Get ( DesktopPath ) ;        PC = "filewin:" & Get ( DesktopPath )] ; Case(Abs(Get ( SystemPlatform )) = 1; MAC; Abs(Get ( SystemPlatform ))= 2 ; PC ) &  $$FileName )]

                Send Mail [Send via E-mail Client ; To: "/*LECT::Work Email*/" Subject: "Teaching assignment for " & COURSE::TERM & " " & COURSE::YEAR ; Message: "/*\"Dear\" & \" \" & LECT::First Name & \",\" & \¶ & \¶ &¶¶\"Attached are the courses you will be teaching next semester.\¶\¶\¶The Organising Committe at UAS Technikum Wien\" & \"\¶\¶\"*/"

                Enter Browse Mode

                 

                The steps up to Pause work fine, but when I continue the script, there is the message: “”could not be created on this disk. Use a different name, …

                When clicking OK, the script opens a new mail message: 

                The TO field reads: /*LECT::Work Email*/
                The Message field contains: 
                /*"Dear" & " " & LECT::First Name & "," & ¶ & ¶ &

                "Attached are the courses you will be teaching next semester.¶¶¶

                The Organising Committe at UAS Technikum Wien" & "¶¶"*/

                 

                The script still works well in the conference solution, and I suspect that the adapted script does not properly get the fields related to LECT. What is wrong here?

                Thank you in advance for your kind support,

                Otto

                • 5. Re: E-mail single PDF page to recipient concerned
                  philmodjunk

                  The error indicates that FileMaker can't save the file to the specified FilePath. This usually indicates an invalid file path. The code you are using to compute this file path is needlessly complex by the way. For saving a PDF, you only need "file:" in place of the "filemac" or "filewin" tags if you are using an older version of FileMaker. IF you are using FileMaker 11 or newer you do not need any of these tags for saving a PDF at all.

                  Just looking at the part of your code that generates the file name, I see numerous errors that will produce an incorrect file name. I suggest starting out with a much simpler file name such as the contents of a single text field and gradually adding in the other details that you want to have as part of the file name one piece at a time.

                  The first error that jumps out at me when I look at the calculation is it looks like the original calculation was imported or copy/pasted from another file as a script step or calculation field. The original expression then contained table or field references that were not valid in your new file and so FileMaker enclosed the original expression in /* comment brackets */ that I can still find as quoted text in your expression. They should be removed.

                  Also, your expression appears to be putting double quotes into the file name in very odd places, probably due to error messages you were getting when trying to put together this calculation.

                  \" evaluates as a double quote character in your text when the above calculation evaluates.

                  I suggest that you review the example in this link that I posted earlier that uses much simpler methods for naming a file: Scripted Find Examples

                  • 6. Re: E-mail single PDF page to recipient concerned
                    otto_m

                    I am blown away by your rapid response, even on a Sunday. Do you never have a day off?

                    You are right, the script was unnecessarily complex and contained many errors. This may have been due to importing the script from another file.

                    Meanwhile I have found the solution in another thread, and it works like a charm:-)

                    Set Variable [$FileName ; Value: "TA_" & LECT::LECT & Substitute ( Get ( CurrentDate ) ; "/" ; "-" ) & ".pdf"]

                    Save Records as PDF [No dialog ; "$FileName" ; Records being browsed]

                    Set Variable [$PDFPath ; Value: Get (DocumentsPath) & $FileName]

                    Send Mail {Send via E-mail Client ; To: LECT::Work Email ; …

                    Thanks again, and have a good day,

                    Otto