10 Replies Latest reply on Aug 1, 2012 8:58 PM by Guy_Smith

    Showing ERROR #3 when executing Insert PDF Script Step

    Guy_Smith

      I thought I had my script to place a pdf copy of a report into an archive Table in FMP 12 up and running, but cannot get past an Error #3 ("Command is Unavailable (for example, wrong OS, wrong mode, etc.") when I reach the Insert PDF script step.

       

      The script works correctly up to that point, printing the original report and saving a copy to the Desktop (which I will turn into a Temp Filepath once I get this bug worked out) with a proper file name (no spaces, colons, or slashes), goes into the Report Archive TO, creates the new record, goes to the right field, and then gives me the error when executing the Insert PDF step. The field is a container field with no special attributes.

       

      Here is the Script:

       

      Go to Layout [ “WeeklyReport” (People) ]

      Enter Browse Mode

      Sort Records [ Keep records in sorted order; Specified Sort Order: People::NameLast; ascending

      People::NameFirst; ascending ]

      [ Restore; No dialog ]

      Print Setup [ Orientation: Landscape; Paper size: 8.5" x 11" ]

      [ Restore; No dialog ]

      Print [ Records being browsed; All Pages; Orientation: Landscape; Paper size: 8.5" x 11" ]

      [ Restore: HP Color LaserJet 1600; No dialog ]

      Set Variable [ $ReportFileName; Value:Let ( [

      tempName = Get(LayoutName) & "_" & GetAsText ( Get(CurrentTimeStamp) ) ;

      cleanName = Substitute ( tempName ; [" "; "_"] ; ["/"; "_"] ;[":";"_"])];

      "file:" & Get (DesktopPath) & cleanName & ".pdf") ]

      Save Records as PDF [ File Name: “$ReportFileName”; Records being browsed ]

      [ Document - Compatibility: Acrobat 7 and later ]

      [ Pages - Number Pages From: 1; Include: All pages ]

      [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ]

      [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ]

      [ Restore; No dialog ]

      Go to Layout [ “ReportArchive” (ReportArchive) ]

      Enter Browse Mode

      New Record/Request

      Commit Records/Requests

      Go to Field [ ReportArchive::Report ]

      //

      //Everything works fine up till the next step - Insert PDF. That is when I get an Error #3

      //

      Insert PDF [ “$ReportFileName” ]

      Go to Layout [ “SplashPage” (NewDB_Master) ]

       

      Hopefully it's something fairly simple, but the problem is just not jumping out at me.

       

      Thanks for taking a look and please let me know if you have any ideas..

       

      Guy

        • 1. Re: Showing ERROR #3 when executing Insert PDF Script Step
          Mike_Mitchell

          Hello, Guy.

           

          A few things to check (off the top of my head):

           

          1) Does the container field allow entry in Browse Mode?

          2) Is the container field optimized for active content?

          3) Does the account under which you're running the script have access to edit the record and the container field?

          4) Are you trying to run this script from Server, or from the client?

           

          Mike

          • 2. Re: Showing ERROR #3 when executing Insert PDF Script Step
            ariley

            Have you tried manually inserting the same file from the Desktop? Does that work? 

             

            agnes b. riley . filemaker and web development

            FileMaker Business Alliance . FileMaker Technical Network

            www.zerobluetech.com (http://www.zerobluetech.com)

             

             

            T 201-299-6223 (NJ) .

            212-842-8830 (NY)

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

            .

            917-660-7221 (C)

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

            FileMaker Certified in 10 and 11

            people + products + events + todos + invoices + documents = productivity

            1 of 1 people found this helpful
            • 3. Re: Showing ERROR #3 when executing Insert PDF Script Step
              Guy_Smith

              Mike and Agnes:  Thanks for looking into this for me...

               

              1.  The container field Does allow entry in Browse Mode.

              2.  Ummmm...Good Question, Bad Answer:  I dunno!  How do I check that?  I can guarantee that my brain is not Optimized for FMP Content!

              3.  Yep, I'm the administrator and have full access privelege set.

              4.  It's just little old me running FMPA on my Mac at home.

              5.  No, I haven't, but that's a great idea!  Should help narrow down a number of possible causes as well as address a couple of Mike's pointers. I'll try that as soon as I can and update you both on the results.

               

              Thanks again,

               

              Guy

              • 4. Re: Showing ERROR #3 when executing Insert PDF Script Step
                Mike_Mitchell

                Guy -

                 

                On #2: Go into Layout mode and check the Inspector. In the Data tab, see what it says at the bottom. If you're doing PDFs, it should look like this:

                 

                container.png

                 

                Mike

                1 of 1 people found this helpful
                • 5. Re: Showing ERROR #3 when executing Insert PDF Script Step
                  Stephen Huston

                  There has also been a report elsewhere on this forum that FMPro, when writing a PDF, may be failing to "let go" of the file it has created so that it triggers an error that the file in question is in use when one tries to manipulate that newly-created PDF.

                   

                  Some speculation:

                  • You might try inserting a step to commit the record, go to the previous record, return to the correct record, and then insert the new PDF. It is possible that changing records might cause FMPro to release the new PDF so it can be used when returning to the correct record. I have not had this error, so have no way to test it myself.
                  • It is also possible that some OS-level writing of the PDF file may not be completed by the time the script step to insert it is being called. A timed pause might help if that's the case.
                  • 6. Re: Showing ERROR #3 when executing Insert PDF Script Step
                    Guy_Smith

                    Okaaaay, Here's the latest:

                     

                    1.  I now have the container field set correctly for PDFs.

                    2.  I CAN insert the PDF into the container field manually (Both Drag&Drop and via the Insert menu)

                    3.  A  3-second delay made no difference - I could see the pdf pop up on the Desktop before executing the next script step, but still no go.

                    4.  Tried the Previous Record and Return steps to unlock the file with no luck, but now get a different error:

                     

                         The file “WeeklyReport_7_31_2012_7_39_48_PM.pdf” could not be found and is required to complete this operation.

                     

                    I'm thinking that the new error is progress of some sort (wishful thinking, perhaps), but I'm completely clueless on where to go from here!

                    • 7. Re: Showing ERROR #3 when executing Insert PDF Script Step
                      ariley

                      Do you have FileMaker Advanced? Do you use the debugger? Does it give you any error at any step? 

                       

                      agnes b. riley . filemaker and web development

                      FileMaker Business Alliance . FileMaker Technical Network

                      www.zerobluetech.com (http://www.zerobluetech.com)

                       

                       

                      T 201-299-6223 (NJ) .

                      212-842-8830 (NY)

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                      .

                      917-660-7221 (C)

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                      FileMaker Certified in 10 and 11

                      people + products + events + todos + invoices + documents = productivity

                      • 8. Re: Showing ERROR #3 when executing Insert PDF Script Step
                        Guy_Smith

                        Hi, Agnes:

                         

                        Yes, I have FMPA  (but pleeeeze don't tell the wife how much it cost!).

                         

                        The erroe code is now 100 and occurs at the same place - when the 'Insert PDF' script step is executed:  The same spot where I used to get the Error #3.

                        • 9. Re: Showing ERROR #3 when executing Insert PDF Script Step
                          RubenVanDenBoogaard

                          Hi Guy,

                           

                          Just a thought, you did not specify on which platform you are, but you could try:

                           

                          Get (DesktopPath) &  "test.pdf"

                           

                          no need for the "file:" on OSX, this way you can be sure that it is not the filename

                          that is bothering you.

                           

                          If it is the filename, use an other option to create an unique filename (if you have to, you could

                          do something like:

                           

                          Get(LayoutName) &

                          " "&GetAsText(Get ( CurrentDate ))&" "&Right("0"&Hour ( Get ( CurrentTime ) );2) & "h" & Right("0"&Minute ( Get ( CurrentTime ) );2) &

                          ".pdf"

                           

                          Hope that helps;

                           

                          Best regards,

                           

                          Ruben van den Boogaard

                          Infomatics Software

                          ruben@infomatics.nl

                          • 10. Re: Showing ERROR #3 when executing Insert PDF Script Step
                            Guy_Smith

                            WOO HOO!!!

                             

                            After mixing and matching all of your suggestions, I finally got it to work:  Ruben's piece of the puzzle recommending I try a 'Test' pdf led me to use the "Add File" button on the Insert PDF script step.  When I clicked on a random pdf file on the Desktop (Cleverly named TEST.pdf), the program gave me the following file path:     image:../../TEST.pdf    which isn't even close to what was generated when I used Get(DesktopPath) when I originally placed the pdf on the Desktop.

                             

                            So I split the file's name off from the $ReportFileName variable and called it $CleanName. 

                                 - To get the file onto the desktop, I added it back into $ReportFileName - As that script step worked correctly, I didn't change it. 

                                 - Then to retrieve the file back from the Desktop and place it in the Report Archive container field, I combined the $Cleanname with that weird desktop filepath and came up with:  Insert pdf [image:././$CleanName]

                             

                            I have no clue as to why Get(DesktopPath) won't work in both script steps, but the script is fully functional and now looks like this:

                             

                            PrintWeeklyReport

                             

                            Go to Layout [ “WeeklyReport” (People) ]

                            Enter Browse Mode

                            Sort Records [ Keep records in sorted order; Specified Sort Order: People::NameLast; ascending

                            People::NameFirst; ascending ]

                            [ Restore; No dialog ]

                            Print Setup [ Orientation: Landscape; Paper size: 8.5" x 11" ]

                            [ Restore; No dialog ]

                            Print [ Records being browsed; All Pages; Orientation: Landscape; Paper size: 8.5" x 11" ]

                            [ Restore: HP Color LaserJet 1600; No dialog ]

                            #Up to here is just simple print script steps

                            #

                            #Now the fun stuff: $CleanName is just for the file's name, but No path.

                            #$ReportFileName includes the path - for now, it's the Desktop, but I may later change it to a Temp Path

                            Set Variable [ $CleanName; Value:Let ( [

                            tempName = Get(LayoutName) & "_" & GetAsText ( Get(CurrentTimeStamp) ) ;

                            cleanName = Substitute ( tempName ; [" "; "_"] ; ["/"; "_"] ;[":";"_"])

                            ];

                            cleanName & ".pdf"

                            ) ]

                            Set Variable [ $ReportFileName; Value:Get (DesktopPath) & $CleanName ]

                            Save Records as PDF [ File Name: “$ReportFileName”; Records being browsed ]

                            [ Document - Compatibility: Acrobat 7 and later ]

                            [ Pages - Number Pages From: 1; Include: All pages ]

                            [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ]

                            [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ]

                            [ Restore; No dialog ]

                            #Now the file is saved to the Desktop

                            Go to Layout [ “ReportArchive” (ReportArchive) ]

                            Enter Browse Mode

                            New Record/Request

                            Commit Records/Requests

                            Go to Field [ ReportArchive::Report ]

                            Insert PDF [ “image:../../$CleanName” ]

                            Go to Layout [ “SplashPage” (NewDB_Master) ]

                             

                            Thank you all so very much for helping me stumble through this.  Your selfless support of us beginners is truly amazing!

                             

                            All the best,

                             

                            Guy