3 Replies Latest reply on Mar 8, 2012 6:15 PM by MilutinPetrovic

    PDF creating robot script

    MilutinPetrovic

      Title

      PDF creating robot script

      Post

      Hello falks!

       

      Being that I am an absolute beginer, last few days I have resolved some serious issues, but this one is to much for me!

       

      Lets say I have a table of products called "Catalog" and it has 2 layouts, one for input of the data, and other for the printing. Being that we have only one copy of filemaker, and that we all use IWP on the local network, I need help creating the robot script that will automaticaly read a certain field (Lets say filed will be called "Print", and we will be selecting "Yes" from the value list), and after that (if the "Yes" is selected), the script will select the specified record, and run another script, which I allready created and which will, in turn, save PDF in a temp location, and than inserting it in a Container field.

      Another good idea would be for the "Print" button in the print layout to copy the ID of the record in the separate table called Print Jobs, and for the script to only read that table, and once it is done, to delete record, in order not to overpopulate it!

      Please please please help! And being that I am a real newbie in the world of FileMaker, it would be nice If someone could give me steps of the script!

      Again I say, PLEASE PLEASE PLEASE! Being thet this is the only wrinkle I have left on my first database, and it is a big one, I must say...

      Thank You! 

        • 1. Re: PDF creating robot script
          philmodjunk

          How will you execute this script on a regular interval? InstallOnTimer Perhaps? (Method depends on whether you host with FileMaker Server or FileMaker Pro.)

          Add this relationship:

          Products::ProductID = PrintJobs::ProductID

          Your "print" script can be:

          Set Variable [$ProductID ; value: Products::ProductID ]
          Go to layout [PrintLog (PrintLog)]
          New Record/Request
          Set Field [PrintLog::ProductID ; $ProductID]
          Go To layout [Original layout ]

          Your "robot" script can be run via robot file or InstallOnTimer to do this:

          Go To Layout [PrintLog ( PrintLog )]
          Enter Find Mode []
          Set Field [PrintLog::PrintedStatus ; "="]
          Set Error capture [on]
          Perform Find []
          If [Get ( FoundCount ) > 0 ]
             Loop
                 Set Variable [$Path ; "File:" & Get ( TemporaryPath ) & "ProductPDF.PDF"]
                  If [ Not Isemtpy ( Products::ProductID ) //check to be sure Product record still exists]
                     Go To Related Record [Show only related records; From table: Products; Using layout: "ProductsPrint" (Products)]
                     Save Records as PDF [Restore; no dialog ; "$Path" ; Current Record]
                     Go to Layout [ProductsDataEntry (Products)] //container field should be on this layout
                     Insert File [Products::ContainerField ; $Path ]
                     Go To Layout [PrintLog (PrintLog)]
                     Set Field [PrintLog::PrintedStatus ; 1 ]
                     Go to Record/Request/page [next ; exit after last]
            End Loop
          End IF

          Note that I haven't set it to delete any records from PrintLog like you asked. Instead, it changes a status field in the record to keep it from being saved as PDF a second time. This allows you to review the print log to confirm what products had a PDF saved. You can modify the above script to find all PrintLog records with a status of 1 and delete them as the final steps of this script if you wish.

          Note: if you are using nothing but Mac computers, you may want to use insert picture instead of insert file.

          • 2. Re: PDF creating robot script
            MilutinPetrovic

            You are a GOD! I love You! :D

            I will test this immediately.

            Oh, and I was planing to use InstallOnTimer script.


            Thanks! 

            • 3. Re: PDF creating robot script
              MilutinPetrovic

              Dear  PhilModJunk,


              once again Your answer has proven itself as extremely helpful! I am saying this because I had a different isue which I resolved using, not the same solution, but the same way of thinking!


              I got to tell You friend, I owe You a beer or two! :)


              THANKS!