7 Replies Latest reply on Jan 20, 2010 5:02 PM by jmmx

    Scripting Save Browsed PDF + Email + Attach PDF

    TigerKim

      Title

      Scripting Save Browsed PDF + Email + Attach PDF

      Post

      I've created a TAPE LOG/WORK ORDER database.

      Having problems with the last step.

       

      1.I've created a Button that will: SAVE browsed WORK ORDERS as a PDF. 

         But a window always opens up, asking me to name the File.

      2.I've createdd a Button that will: Create an EMAIL with the ADDRESS, SUBJECT, MESSAGE already filled out.

         But this will only allow me to attach a specific file. 

       

      How can I combine the two into one button? (i.e. Save PDF, Name PDF File, Email, Attach PDF file)

       

      I'd appreciate any and all advice. I've read several posts and still can't get this to work.

      Thanks.

       

      Tigerkim

        • 1. Re: Scripting Save Browsed PDF + Email + Attach PDF
          Orlando
            
          Hi Tigerkim
           
          You need to set the path of the PDF you are creating in a Variable and use that path in both the Save As Pad script step and the Attachment option for Send Mail step.
           
          To do this when setting up the Save As PDF, there is an option 'Specify output file', click specify and type in the name of your variable [$FilePath] and then for the Send Mail step, under the Message text area there is a tick box of 'Attachment', tick this and input the variable name in the dialog that pops up.
           
          Below is how the script would look if you saved the PDF in the Temporary folder, this removed when you shut down the machine.
           
          #
          Got to Layout ["YourReport"] 

          Set Variable [$FilePath ; "filemac:" & Get ( TemporaryPath ) & "FileName.pdf"]

          Save Record as PDF [No dialog; "$FilePath", Current record]

          #PDF has been created, now attach and send in email

          Send Mail [To:"email@domain.com"; subject: ... ; "$FilePath"] 

           

          The above variable for file path is for use on a Mac, if you are windows based change 'filemac:' to 'filewin:'

           

          I hope this helps 

          • 2. Re: Scripting Save Browsed PDF + Email + Attach PDF
            TigerKim
              

            Orlando,

             

            YOU-ARE-AWESOME!

            Thank you so much for your sharing your skillz with a newbie. It worked! I know that many users will definitely find this helpful.

             

            My last question. How do I keep the SAVED PFD FILE in the FOLDER for future use. As you have

            instructed, the file doesn't even appear in the folder.

             

            Thanks again. And Happy New Year!

             

            TigerKim.

            • 3. Re: Scripting Save Browsed PDF + Email + Attach PDF
              AAgraphics
                

              Hello Orlando,

               

              I have a related question:

               

              1) Using FileMaker 10

              2) Mac OS 10.6 and Windows

              3) The database is used by multiple people in FileMaker over the internet by both PCs and Macs.

               

              4) Here's is what I am trying to do:

               

              We have a page on the database where multiple email addresses are entered.  After the email addresses are entered, we are trying to make it so you can click on a button and FileMaker will automatically create a PDF of that page (the record in that specific layout) and email the PDF as an attachment through FileMaker to all of the recipients listed in the first sentence of this paragraph.  People using Macs and PCs will be using this feature.  In addition, they are accessing the FileMaker database over the internet and they are using FileMaker.

                

              • 4. Re: Scripting Save Browsed PDF + Email + Attach PDF
                TSGal

                AAgraphics:

                 

                Thank you for your post.

                 

                Are the multiple email addresses in separate records?  Or, are they all listed in a text field?  If the latter, how are the addresses separated?  If separated with a comma or semi-colon, depending on the email client, you should be able to send one email to the entire group.

                 

                The example by Orlando is correct (Thank you!).  This should work for you, but since you are posting, I assume it is not working.  What is happening?

                 

                TSGal

                FileMaker, Inc. 

                • 5. Re: Scripting Save Browsed PDF + Email + Attach PDF
                  AAgraphics
                     Everything is working, but I had to make one button to send for people using Macs and another button to send for people using PCs.  Is there a common path I can use to save the PDF that will work for both Macs and PCs?
                  • 6. Re: Scripting Save Browsed PDF + Email + Attach PDF
                    TSGal

                    AAgraphics:

                     

                    You can combine the buttons into one by changing the calculation for the variable:

                     

                    If ( Abs ( Get ( SystemPlatform ) ) = 1 ; "filemac:" ; "filewin:" ) & <path name> & <PDF file name>

                     

                    Then reference the variable for the destination.  This will then work correctly for Mac and Windows.

                     

                    TSGal

                    FileMaker, Inc. 

                    • 7. Re: Scripting Save Browsed PDF + Email + Attach PDF
                      jmmx
                        

                      Orlando,

                       

                      Thanks for a good, detailed reply.

                       

                      It would have been a lot easier if the Dialog box for specifying the file to attach to the email actually had a note that you can use a variable here. That would have saved me an hour or two.