7 Replies Latest reply on Aug 20, 2015 9:41 AM by philmodjunk

    Saving PDF’s with specific name and choice of where to save.

    BrentJohnson

      Title

      Saving PDF’s with specific name and choice of where to save.

      Post

      I am wanting to create a script that allows me to choose where a PDF is saved to, but saves as a specific name.

      EX: I have a record I want to save as a PDF with “ & ${Projects Set-Up}::__Store Number & " Quote.pdf" ) assigned as to the PDF name.  I want to determine where to save the PDF.

        • 1. Re: Saving PDF’s with specific name and choice of where to save.
          philmodjunk

          I recall answering this question once before and quite recently...

          Calculate the file path to the temporary folder with the file name that you want appended to the end of the file path in a Set Variable script step so that the variable is set to this file path.

          Set Variable [$FilePath ; value: Get ( TemporaryPath ) & ${Projects Set-Up}::__Store Number & " Quote.pdf" ]

          Use Save As PDF to save the PDF with this variable.

          Use Insert File and this same variable to automatically insert this file into a container field.

          Now use export Field Contents to export the file, but without specifying the location. A dialog will open where the user can choose where to save this second copy of the file. By saving the original copy to the temporary folder, no extra copy is left on the user's computer as the contents of the temporary folder are not retained.

          Admittedly, this does enable the user to rename this last copy of the file and that might not be acceptable, but at least the default name of the file will be what you specified at the beginning of this script.

          Alternative methods:

          If there are a small number of specific places that are all you wish to permit the user to select from as the save destination, you can set up a value list on a global text field and use the contents of this field in the calculation that determines the filepath and then you only need Save As PDF with that variable in order to save the file with a calculated file name and a user selected location.

          There are Plug Ins that you can acquire to extend what FileMaker can do. It's possible that there is a plug in that will enable you to open a dialog for selecting the file location without also allowing the user to rename the file. You'd have to do a web search and see what is available.

          • 2. Re: Saving PDF’s with specific name and choice of where to save.
            BrentJohnson

            Phil,

            Thank you much for your responce.  However, i must be doing something wrong as this is not working.  The following is the script that i am running, but nothing happens.

            • 4. Re: Saving PDF’s with specific name and choice of where to save.
              philmodjunk

              You have to three different table occurrences in this script. You have at least two different layouts involved. I can't see your data model but both Context Issues and Layout Design Issues might be keeping your script from working. Also, while you will want "Set Error Capture" to be in place once your script is working, the fact that you have it at the beginning of your script at a time when you are still trying to get it to work will keep error messages that might be telling you what isn't working from being displayed. So you might temporarily remove or disable that script to see if an error message appears when you run your script.

              The most obvious possible issue is that all script steps that begin with "insert"--such as insert file will silently fail to work if their specified target field is not present on the current layout at the time the step executes. In addition, the container field is from a different table occurrence from that of the layout so this can also fail if the container field does not have either global storage or the data model doesn't allow access to a record from that table occurrence when the context is your that of your current layout's table occurrence.

              • 5. Re: Saving PDF’s with specific name and choice of where to save.
                BrentJohnson

                I created a test layout using the following script - still nothing happens.

                • 7. Re: Saving PDF’s with specific name and choice of where to save.
                  philmodjunk

                  There is no need for preview mode here.

                  and I don't see the point to the adjust window and go to layout steps at the end.

                  Try putting a pause script step immediately after the save as PDF. I suspect that FileMaker starts up the "save" process and then advances to the next step before PDF is generated and thus it tries to insert a file that does not yet exist at the moment when it is attempting to insert the file.