3 Replies Latest reply on Jun 16, 2011 2:04 PM by philmodjunk

    Error Capture Script and Bypassing Filemaker Errors



      Error Capture Script and Bypassing Filemaker Errors


      For this application, I use Filemaker Pro Advanced to store my database of scientific literature.  Every record has a container field that contains the PDF of the article.  I have created a script for my button that uses ExportFieldContents with automatically open, and gives it a name "test.pdf".  However, I need to close that file before opening another or I get a Filemaker error message: "test.pdf" could not be created on the disk....  That's because the file it is trying to save to is open.  To get around this problem, I wanted to modify my script with an "if" statement that would use ErrorCapture and GetLastError.  I would then say, if this file is used, use Test1.pdf etc.  However, as soon as the script gets to the line with ExportFieldContents the error I mentioned pops up, without ever getting to the next line in the code.  Is there any way around this?

        • 1. Re: Error Capture Script and Bypassing Filemaker Errors

          Set Error Capture [on] suppresses most error dialogs, but not this one due to a Error Capture.

          Here are some alternatives:

          Store a name in a text field and use it with Export Field Contents to open each file with a different name.

          Assuming each PDF file is stored in the container field of a different record, define an auto-entered serial number field and include this unique ID number in the file name.

          Use a global variable to count the number of times Export Field Contents has opened a file in  the current session. Include this counter as part of the file name.

          • 2. Re: Error Capture Script and Bypassing Filemaker Errors

            That's what I'm trying to do.  Each record has it's own ID number.  How do I incorporate this field information as part of the file name? I tried: test[document ID].pdf, and the system thought [document ID] was part of the text file name, and not the data contained in the field for that record.

            • 3. Re: Error Capture Script and Bypassing Filemaker Errors

              You need to set this up as a text expression that includes the contents of your field.

              You should be able to use an expression such as this to set your file path variable:

              Set Variable [ $Path ; "file:" & Get ( TemporaryPath ) & YourTable::DocumentID & ".PDF" ]
              Export Field Contents [ YourTable::YourContainerField ; "$Path"]

              PS. Get ( TemporaryPath ) returns the file path to your temporary items folder--a useful place to which to export such files when you just want to open them.