6 Replies Latest reply on Nov 14, 2013 11:02 AM by DavidMcnaughtan

    Save Records as PDF, FMPA 12

    DavidMcnaughtan

      Title

      Save Records as PDF, FMPA 12

      Post

           I need to write PDFs of each of my records in a file and then attach them to an Email.

           Using the set up as below, I always get an error code 5.

           If I don't specify an option, then the record choice defaults to "records being browsed", which I don't want, and the "restore" as first variable disappears. I can change each individual entry manually to "current record", but that is extremely time consuming. The programme is trying to write to a file "restore" it seems, which causes the Error code 5. Is this a known bug?

      2013-11-14_00-45-37.jpg

        • 1. Re: Save Records as PDF, FMPA 12
          philmodjunk

               "Restore" is not the name of the file it is trying to produce with Save As PDF. It indicates that you have Stored options as part of the script step.

               Error code 5 means "command is invalid" and is typical of a script step that is missing a needed parameter.

               That doesn't make sense for the script as you have written, which looks correct to me except for the fact that since every PDF is saved with the same name to the same location, each new PDF replaces the previous one. Your loop should name the PDF with something unique by setting that value to the variable inside the loop.

               If there is an error with Save As PDF, you should get an error dialog popping up. Is such an error appearing? Is a PDF named "SEPA" being created?

                

                

          • 2. Re: Save Records as PDF, FMPA 12
            DavidMcnaughtan

                 I am indeed overwriting the "SEPA.PDF" with new values each round, as the current values are only needed to produce the required Email. In fact the script works perfectly when manually altering the record choice to "current record", but I can see no reason technically, why it should not do so with an option set in the dialog under "specify options". The error pops up using the script as pictured. 

                 The save records as pdf line using manual record choice is : ["$filePath"; Records being browsed]

            • 3. Re: Save Records as PDF, FMPA 12
              philmodjunk

                   But is the PDF actually being created? Are the emails sent with the expected attachments when you run the script if you remove or disable the If step that checks for an error code?

              • 4. Re: Save Records as PDF, FMPA 12
                DavidMcnaughtan

                     Yes indeed, as I already wrote, with manual correction to "current record", the email is correctly created wirh the required record dependent details and the file then is overwritten by the next pdf for the nextcurrent record. 

                     If I leave the default "records being browsed", but as above with no entry in the options menu, then the emails are also all created, but with the pdf value always from the first record. The email address is however the correct one. 

                     Refusing to write in "options mode" I see as a bug

                • 5. Re: Save Records as PDF, FMPA 12
                  philmodjunk
                       

                            Yes indeed, as I already wrote, with manual correction to "current record", the email is correctly created wirh the required record dependent details and the file then is overwritten by the next pdf for the nextcurrent record.

                       That's not what I meant to ask. If you remove the IF function or disable it and run your script. Does the SCRIPT create and email your PDF files? The fact that you can manually save as pdf or that you can have the script save as PDF if it stops and displays a dialog for saving the PDF each time is not what I am asking you to check. In fact, that reveals a missing setting on your script that I had not noticed. Unless you want to see a dialog box appear for each emailed PDF, you should have also selected the "perform without dialog" option as there would appear to be no reason to have the dialog appear when you are using a path variable to specify the name and location for the PDF file.

                       I also suggesting that you try deleting the save as PDF script and then adding it back into your script. The error message suggests that a required parameter is missing or perhaps a parameter has been specified incorrectly (perhaps as an "option" for the PDF). But it could also be due to a corrupted script or script step.

                       If all else fails, try creating a brand new script for this and see if it has the same issue. The most extreme test for issues is to use a completely new test file (don't reproduce your original file, just make a simple file with a few records and a very basic layout and test your script in it...) to see if the file itself might be damaged.

                       

                            Refusing to write in "options mode" I see as a bug

                       I can see why you have that opinion and it is a possibility here, but save as PDF is a very frequently used script step and I'd expect to see numerous reports of such a problem over in Report an Issue if this were a bug.

                  • 6. Re: Save Records as PDF, FMPA 12
                    DavidMcnaughtan

                         Deleting the "Save Records as PDF" line and reinstating it did the trick, now it works. Thank you :-)