3 Replies Latest reply on May 11, 2012 10:14 AM by wesfolio

    Naming a PDF dynamically from a field within my file: PART 2

    wesfolio

      Title

      Naming a PDF dynamically from a field within my file: PART 2

      Post

      I have a database that produces invoices. I'd like to be able to save each invoice as a pdf with the invoice number in the name. I need to be able to save this pdf file in a specific folder in my business documents.

      An older post from 2011 named,"Dynamically naming a PDF" addresses the issue of saving a PDF with a name from a field such as an invoice number.

      It works great, but only saves to the desktop. It uses the "Get (DesktopPath)" function within the variable options. I've found a list of "Get" functions and none seeem to allow for a specific folder path.

      Is there a way to make this kind of script work, but be able to save to a specific folder?

      Below is the script that saves to the desktop only:

      The following example assumes that your file is named 'MyFile' and the field that is used to name the PDF is 'PDFName'.

      Create the following script:

      Set Variable (*see set variable options below)
      Save Records as PDF [Restore; No dialog; "$filePath"; Current record]

      *Set Variable Options:
      Name: $filePath
      Value: Use one of the following formulas

      Mac:
      Get ( DesktopPath ) & MyFile::PDFName & ".pdf"

      Windows:
      "filewin:"& Get ( DesktopPath ) & MyFile::PDFName & ".pdf"

      Mac and Windows:
      Choose ( Abs ( Get ( SystemPlatform ) ) -1 ; Get ( DesktopPath ) & MyFile::PDFName & ".pdf" ; "filewin:"& Get ( DesktopPath ) & MyFile::PDFName & ".pdf" )

      Repetition: 1

       

       

       

       

       

        • 1. Re: Naming a PDF dynamically from a field within my file: PART 2
          philmodjunk

           

          You would replace Get ( DesktopPath ) with the path to the folder where you want to store your PDF's.

          You also do not have to use Get (SystemPlatform) with a different file path for each system. You can use:

          "file:" & /*put your file path here */ & MyFile::PDFName & ".pdf"

          as the value for the path variable on both platforms.

          In windows, you can right click your folder and select properties to see and copy the path you need to use in your calculation. I think you can use Get Info on macs to do the same thing.

          • 2. Re: Naming a PDF dynamically from a field within my file: PART 2

            I use a table to hold pathnames which I can acquire as PhilModJunk pointed out.

            Then my script finds the record using another field as an identifier.

            Then it is a simple matter of use set variable $_filename to table::pathname & pdffilename

            The value here is that the pathname can be changed at any time without having to modify a hardwired pathname in a script.

            In my local file backup script I use this idea but for the backup I loop through multiple records saving a copy in 3 or 4 different folders when I close the file or anytime I activate the script.

            So using a similar idea you could save the pdf to your designated folder(s).

            • 3. Re: Naming a PDF dynamically from a field within my file: PART 2
              wesfolio

              Thanks for the suggestions and support.

              In the end, I used a Let function in my variable with the path to the folder and naming parameters included. I only use this on my Mac so this simple script did the trick.

              Let( [

                  mainpath = "/drive/Users/me/Documents/business/" ;

                  name = INVOICES::invoiceNumber &" " & Clients table::CoCode ;

                  extension =  ".pdf" ] ;

              mainpath & name & extension )