8 Replies Latest reply on Dec 15, 2016 4:43 PM by JackRodges

    Should Save as PDF replace existing pdf?


      Hi all,


      I have my sales team using a database that I have developed on thier ipads. I am having trouble with the "Save as PDF" script - when used for the first time to create a pdf form (ie product order) to be emailed back to Head Office, it works fine.


      But then when a rep enters info for a new order, then does the same process, the original pdf is attached - the script hasn't "saved as" and replaced the previous pdf form with the new one. I then go in and check, and the new info is there and I can create a pdf using the info ok.


      Its like once its used once, it won't replace the pdf the next time. The only way to clear it is to get them to delete the pdf from the file list.


      The reps are using ipad 2s and all have the latest OS version.


      Any suggestions on how to get around this?



        • 1. Re: Should Save as PDF replace existing pdf?

          can you post a screenshot of your script? According to the go development guide (I don't have my iPad to test), you can overwrite existing PDF files by specifying a variable path and saving the PDF to that variable path with NO dialog.




          set variable $path = get(documentspath) & "file.pdf"

          save records as PDF - no dialog - $path

          • 2. Re: Should Save as PDF replace existing pdf?

            Thanks Mike!


            Here is a screen shot of the script (with email info removed ) - it works fine, except it doesn't save over the previous one! It is a bit different to what you have written.



            • 3. Re: Should Save as PDF replace existing pdf?

              A couple of questions—


              1.     Have you checked to see that you are getting multiple copies of the pdf document saved?

              2.     Does a pdf get overwritten if original is from the same iPad as the the replacement, but not overwritten if the replacement is from a different iPad?


              Depending on the above, it strikes me that the problem could be a different document path depending on which iPad saves/retrieves the pdf.

              • 4. Re: Should Save as PDF replace existing pdf?

                In answer to your questions


                1. There is only one file saved, the original one...no multiples showing. If I delete the original one via the file area, it then will create right one appropriately. But then try again, and the previous one shows up.

                2. It doesn't get overwritten at all - thats the wierd thing. Same file name too. It is like it is an issue with the document path but I don't know where else it would save it.


                And a new record is created in Filemaker Go so its not like the data isn't there...


                Very strange!

                • 5. Re: Should Save as PDF replace existing pdf?

                  Interesting. I regularly use a similar process to save quotes, invoices and letters as pdf's, and occasionally have to make subsequent corrections and re-save them, and I have never had an issue; the pdf is always overwritten. This is working on a MacPro using FMP/FMS. I don't know whether FMGo is giving you grief, as I have no siginifcant experience with it Go yet, but as Mike points out, it should work according to the development guide.


                  It might be worth testing the process in FM on a desktop or laptop to see if you get the same result as your are getting in FMGo. Another thought is to check permissions to make sure you don't have some sort of conflict there that is preventing replacement of a pdf—a Finder level problem, so to speak.

                  • 6. Re: Should Save as PDF replace existing pdf?

                    Based on your screenshot, your $FileName variable is not fully qualified. I believe you have to use:


                    "file:" & "ConcernsRegistration.pdf"


                    See this creating file paths note:



                    And also page 13 in the Filemaker GO development guide:



                    The second link reads:

                    To replace the output file with the new one instead of keeping multiple copies, add the file path (file:fileName or filemac:fileName) to the script. For example, if you type file:sample.pdf or filemac:sample.pdf in the Specify Output File dialog each time you run the script, the sample.pdf file in the Documents folder will be replaced with the new one.


                    Also, make sure you add error capturing. At the beginning of your script place a "set error capture - on" script step, then at the end of your script place a "show custom dialog" script step that has a body calculated as Get(LastError). If there is any error, it will display the number. You can disable the dialog box once it's working. Any error other than 0 would be suspicious.

                    • 7. Re: Should Save as PDF replace existing pdf?

                      Thanks Mike!


                      I spent some time playing round with my existing script, but I kept ending up with the pdf refreshed, but then it wouldn't attach to the email! It was a total mystery as to where the files were saving if they weren't saving into the documents folder on the ipad.


                      Not sure what I was doing wrong so decided to start again and try the script using the temporary path as described on page 13 of the Filemaker Go Developement guide, and that seemed to do the trick on my ipad.


                      Have now set it up in the live database so will see if that fixes the issue!


                      Will let you know...fingers crossed that is now sorted!


                      Thanks again!

                      • 8. Re: Should Save as PDF replace existing pdf?

                        The first time you create the script, the pdf doesn't exist so you don't have the option of telling FileMaker to overwrite or not (unless the file exists).


                        So, open the script and modify the save as script so that you are entering the save info fresh and new. It will notice the existing file and ask if you want to overwrite it which it didn't do since it didn't exist.


                        Note: a problem is encountered if people open the pdf and don't close it before running the script and if your script doesn't handled this error or captures the error and proceeds, the old file remains intact and possible may be sent rather than a new one which wasn't created. You will need to trap the error, tell your user to close the file and run the script again and exit script.