14 Replies Latest reply on Aug 7, 2017 2:17 PM by jodieshops

    Found Sets to PDF with unique file names

    EricPingel

      Title

      Found Sets to PDF with unique file names

      Post

      Looking for a way to export class rosters into individual PDFs with unique file names.

      Desired file names are created by using a field in the DB that contains text data

      Eventually this will be an automated process that will produce more than 50 unique rosters in PDF form

      Thank you,
      --Eric 

        • 1. Re: Found Sets to PDF with unique file names
          mgores

          The way I have done it is to define a variable  $filename  using the field you want to make the filename for the calculation.  i.e.  filenamefile & ".pdf"

          The have the script do the save file, print to pdf or export as pdf using your variable for the file name.  You will also have to give it a file path to put the file into, which can be another variable that you define as well or a set path if they will always go into the same folder.

          • 2. Re: Found Sets to PDF with unique file names
            philmodjunk

            Here's a section of script adapted from a file where we do this very thing:

            Set Variable [ $Path ; Value:  "file:" & Get ( DesktopPath ) & YourTable::FileNameField & ".PDF"]
            Save Records as PDF [Restore; no dialog ; "$Path" ; //specify the other options you need for your script here]

            Get ( DesktopPath ) returns the file path to your user's desk top folder. You can use other Get functions to other standard locations or you can construct a literal filepath starting with a drive letter ( windows ) or a volume name (mac) and then listing all the enclosing directories separated by the / character.

            • 3. Re: Found Sets to PDF with unique file names
              EricPingel

              Thank you both!  That solved it!

              Thank you very much :)

              • 4. Re: Found Sets to PDF with unique file names
                mgores

                Have also found it useful in our application to have a container field which has the resulting pdf file stored as a reference. 

                Then you can set a button to open the pdf so that users do not have to go looking through folders for it.

                • 5. Re: Found Sets to PDF with unique file names
                  DougTroyer

                  I am having trouble getting this statment to work for some reason I cannot get the filename to be set as an Variable.  I am trying to generate a calculated filename for an export as PDF.  I have a feild within my table that is creating the filename but cannot get the filename feild pull in as the filename of the generated PDF.  In this statement Set Variable does not work I must use $variable.  Do I need to use some other command for the file name?  i know that I must be doing something wrong but am not sure what.  Note I am using FileMaker Pro 11 in Windows XP pro perhaps that changes something.

                  Doug

                  Set Variable [ $Path ; Value:  "file:" & Get ( DesktopPath ) & YourTable::FileNameField & ".PDF"]
                  Save Records as PDF [Restore; no dialog ; "$Path" ; //specify the other options you need for your script here]

                  • 6. Re: Found Sets to PDF with unique file names
                    mgores

                    Doug,  you might try inserting a show dialog step in your script and have it display $Path so you can double check that the variable is being set correctly.

                    • 7. Re: Found Sets to PDF with unique file names
                      philmodjunk

                           @Doug,

                           I was using FMP 11 and Windows XP when I first posted to the original thread from which this was taken so there are no version/platform issues involved.

                           As Mark as suggested, I'd take a look at your table and record context to see if the data in your field is actually making it into this calculation. You might also temporarily substitute a file name in quotation marks such as "TempFileName.PDF" in place of YourTable::FileNameField & ".PDF" to see if it then works. If it does not, the problem lies elsewhere.

                      • 8. Re: Found Sets to PDF with unique file names
                        brian.curran

                             Hi,
                             I managed to get this working perfectly on a local file but when I try it on my hosted file, the email doesn't include the file attachment.

                             Also; we use Macs and PCs, do we need to set anything extra up due to the platform differences?

                             Thanks
                             Brian. 

                        • 9. Re: Found Sets to PDF with unique file names
                          brian.curran

                               Following on from above:

                               I have a Calc field which generates a comma separated list of email addresses for a Site
                               Substitute ( List ( People.Site::WorkEmail ) ; "¶" ; " ; " )

                               This works fine in that it displays the email address of all People associated with a Site. However, I want to filter the list to only display those who hold a particular role at the Site. Elsewhere in a portal, I use the following filter:
                               not IsEmpty ( FilterValues ( _JoinPeopleSite::Role ; "Incidents" ) )

                               Can I combine these two somehow in the Calculation field?

                               Thanks
                               Brian.

                          • 10. Re: Found Sets to PDF with unique file names
                            MEGolab

                                 I know everyone else seems to get this to work and i just keep getting and error message.

                                 "C:/Users....../BOL EmailsSH1300.PDF" could not be created on this disk.  Use a different name, make more room on the disk,

                                  

                                 Hopefully my image of the script uploads.  Any help is appriciated.  The file location is on the same computer as the database, running windows 7

                                  

                            • 11. Re: Found Sets to PDF with unique file names
                              philmodjunk

                              Threads where the initial post is more than 3 months old no longer automatically appear in recent items when a new comment is posted to them Thus, others are unlikely to notice when you post a question to them. You are better off starting a new thread than posting to one this old. Since Feburary 2011--the date of the first post to this thread, we don't even use the same version of Filemaker.

                                   That said, the syntax shown in your script looks correct. There are no obvious errors.

                                   Possible explanations for this error:

                                   The file path may be invalid. One of the specified folders may not exist or may have a different name.

                                   The specified location many not be one for which the current user has "write permission".

                                   User account permissions could be damaged in some way.

                                   Your hard drive may lack available space or may be corrupted.

                                   An invalid file path is the most likely explanation in my experience. See this thread for more info on File paths, path variables and a file you can download that you can use to create a valid filepath to a file that is located in the folder into which you want to save your PDF: Exploring the use of a $Path Variable in Scripts

                              • 12. Re: Found Sets to PDF with unique file names
                                malibux14x

                                     like a charm.

                                     & ".pdf"

                                     thanks!

                                • 13. Re: Found Sets to PDF with unique file names
                                  zaza

                                  I am getting same error as Josh (...pdf could not be created on this disk...) . josh (or anyone) can you clarify how you finally got script to work please

                                  • 14. Re: Found Sets to PDF with unique file names
                                    jodieshops

                                    This worked great for me.  I also was able to use a send email script and the same variables to attach the created pdf to a personalized configurable email.

                                     

                                    Thank you!