8 Replies Latest reply on Sep 1, 2016 5:51 PM by CarlSchwarz

    PDF saved to a Container filed

    ajayz

      Hi,

      I would like to add a SCRIPT to button within my database, that will generate a PDF of the current record and save the PDF  into  a container field.

       

      Currently I use this script to generate the PDF and attached to an email, but would like to modify it to only save the PDF in a container field (Email will not be required)

       

      The container field is called: illumination::ReportPdf

        • 1. Re: PDF saved to a Container filed
          user19752

          If you need only saving the PDF, "Insert File". If you need view it in FM, "Insert PDF" with interactive container.

          Both need a layout that have the container field in it.

          • 2. Re: PDF saved to a Container filed
            CarlSchwarz

            Instead of send mail do this:

            Go to field (container field)

            Insert PDF ($PATH)

             

            Make sure that the container is on the layout.

             

            Edit... Timing   .  It almost looks like a double post!

            • 3. Re: PDF saved to a Container filed
              ajayz

              Hi thanks guys for the quick reply.

               

              I updated my script:

               

              Screen Shot 2016-09-01 at 3.22.33 PM.png

               

              I've added the container [ReportPdf] to the form.

               

              However, when I run the script it is not working.. it seems to to stop on the selected report form view.  When i go back to the form and check the container - it's empty.

              • 4. Re: PDF saved to a Container filed
                user19752

                You missed "Go to Layout [the layout with container] before "Go to Field".

                And the container should be set as "interactive content" in layout mode.

                And "Insert PDF" need the path as

                image:$PATH

                (screen capature shows it as same as without "image:")

                1 of 1 people found this helpful
                • 5. Re: PDF saved to a Container filed
                  Vaughan

                  The trapping of errors on the GTRR step is causing problems.

                   

                  If using GTRR for the current record only, check for related records with IsEmpty( relationship::primary_key ) before the GTRR step

                  --

                  If [ IsEmpty( relationship::primary_key ) ]

                  # no related records

                  exit script

                  End If

                  Go to Related Records [ ]

                  --

                   

                  If the GTRR uses the found set then trap for the error from the GTRR step, but be aware that if the first  record has no related records a 101 error will be generated, even though the step will return the related records from the other found set. If no related records match the found set the 401 is returned. So the error trapping ends to be a bit more sophisticated:

                   

                  Set Error Capture [ on ]

                  Go to Related Records [ found set ]

                  Set Variable [ $error ]

                  Set Error Capture [ off ]

                  If [ $error ≠ 0 and $error ≠ 101 ]

                  # no related records for found set

                  End If

                   

                  Remember that if the GTRR step running for the found set find no related records, it does not change layout.

                  1 of 1 people found this helpful
                  • 6. Re: PDF saved to a Container filed
                    keywords

                    If you study the dialog boxes for output and input specs you will see what you are missing.

                    1.     Output: i.e. Save as PDF

                    Note that you require text before the actual path, in one of the formats specified—file:, filemac: or filewin:. If you are declaring a variable you must include this text in the variable.

                    Screen Shot 2016-09-01 at 4.30.44 PM.png

                     

                    2.     Input: i.e. Insert Picture or Insert PDF

                    Note that the text now requires use of the word "image" instead of "file". Again, you need to include this in your variable.

                    Screen Shot 2016-09-01 at 4.30.59 PM.png

                     

                    My technique for this operation, which I do a lot (e.g. Save a letter as a PDF, and insert the saved letter into a container field), is to declare both versions—$filepath and $imagepath—at the start of the script and then call the appropriate one as needed further down the script.

                    • 7. Re: PDF saved to a Container filed
                      ajayz

                      Thanks for your help, I have it working find on the PC/Mac using Filemaker Pro, however is there something else I would need to change for it to work on FileMaker Go 15?

                       

                      When I run it on the iPad (latest update) - i get a window displayed with the heading" Files on iPad' and then within the window "No files available".

                       

                      Thanks

                      • 8. Re: PDF saved to a Container filed
                        CarlSchwarz

                        There are a few gotcha's with FileMaker Go.   Re: How To Create A Button To Create/Email PDF In Filemaker Go

                         

                        There is a sample file in the thread above, and some discussion about some of the unique behaviours of FileMaker Go