1 2 Previous Next 16 Replies Latest reply on May 6, 2011 7:55 AM by zendolphyn

    Using Save ad PDF script step with a sub-summarized letter

    laneystewart

      Title

      Using Save ad PDF script step with a sub-summarized letter

      Post

      I have a letter that uses a sub-summary to total information in the middle of a letter.  I have the letter looking perfect in preview, but now want to save that letter to PDF and send it as an email attachment. I have set up the variable to save the letter with a unique name in a file and can get the email part to work fine, but I can not get the letter to print to PDF in the summarized style as the script step only allows you to use the print the current record or print the records being browsed.  Does anyone have an idea of how to get this to print the summarized letter??  Any help would be greatly appreciated!

       

      LANEY 

        • 1. Re: Using Save ad PDF script step with a sub-summarized letter
          deltatango
            

          There is a script steps called save records as PDF.

           

          Use that instead, not print when in preview mode and you should be fine.

           

          • 2. Re: Using Save ad PDF script step with a sub-summarized letter
            laneystewart
               Thank you, but I already use that, the problem is that I can not get it to save as PDF according to page of the final output, not record.  When I use the save as PDF script step, it only allows me to use the either the current record or all records being browsed.  I need each page of the set to be printed and attached to a separate email. 
            • 3. Re: Using Save ad PDF script step with a sub-summarized letter
              TSGal

              laneystewart:

               

              Thank you for your post.

               

              When you Save as PDF, it will create ONE file.  If you want each page as its own file, then you will need to access Save as PDF one time for each page.  Here is a sample script that I'll explain later:

               

              Go to Record [First] 

              Set Variable [ $page ; 1 ] 

              Loop

                 Save Records as PDF [ No dialog ; "File" & $page & ".pdf" ; Current Record ]

                 Go to Record/Request/Page [ Next ; Exit after last ]

                 Set Variable [ $page ; $page + 1 ]

              End Loop

               

              ------------

               

              That is, we go to the first record of the found set.  We then initialize a variable to 1 (discussed later).

               

              We then enter the loop where we Save Records as PDF to the file "File1.pdf", and we only print the current record.  We then skip to the next record and increment the $page variable by 1, so it is now 2.  We then go back to the top of the loop and Save Records as PDF to "File2.pdf".  We needed to change the name of the file.  Otherwise, we would overwrite the file each time.  That is the reason for the $page variable.

               

              After going through all the records, when we encounter "Go to Record/Request/Page [ Next ; Exit after last ]", we exit after the last record.

               

              This should get you pointed in the right direction.  Please let me know if you need clarification for any of the above steps.

               

              TSGal

              FileMaker, Inc. 

              • 4. Re: Using Save ad PDF script step with a sub-summarized letter
                laneystewart
                  

                TSGAL,

                 

                I understand that will print a page for each record, but is there a way to use the sub-summary to write a page for more than one record??  I have a sub-summary that has one record for several of it's pages, but then there is a page of the final PDF that has 3 records on it. Is there any way to get that info together or should I use a GetSummary type of field???  Thank you.

                  

                • 5. Re: Using Save ad PDF script step with a sub-summarized letter
                  TSGal

                  laneystewart:

                   

                  Thank you for the clarification.

                   

                  Yes, the script I gave you was to print a page for each record.  If you want to modify it so you print a page for each grouping of records, then change the script to:

                   

                  Sort Records [ Restore ; No Dialog ]

                  Go to Record/Request/Page [First]

                  Loop 

                     Set Variable [ $key ; <key field for grouping> ]

                     Save Records As PDF [ No dialog ; "File" & $page & ".pdf" ; Records being browsed ; page range 1 to 1 ]

                     Loop

                        Omit Record

                        Exit Loop If [ <key field for grouping> ≠ $key

                     End Loop

                     Exit Loop If [ Get (FoundCount) = 0 ]

                  End Loop 

                   

                  -------------------

                   

                  This will print each page separately, assuming you have a sub-summary that begins on a page break.

                   

                  TSGal

                  FileMaker, Inc. 

                   

                  • 6. Re: Using Save ad PDF script step with a sub-summarized letter
                    laneystewart
                       TSGAL... YOU ROCK!!!! Thanks for the help!  Works like a charm!!!  I have it emailing the pdf's as attachments to the schools they need to go to!!!!  
                    • 7. Re: Using Save ad PDF script step with a sub-summarized letter
                      AAgraphics
                        

                      Hello TSGal,

                       

                      I have a related question:

                       

                      1) Using FileMaker 10

                      2) Mac OS 10.6 and Windows

                      3) The database is used by multiple people in FileMaker over the internet on both PCs and Macs.

                       

                      4) Here's is what I am trying to do:

                       

                      We have a page on the database where multiple email addresses are entered.  After the email addresses are entered, we are trying to make it so you can click on a button and FileMaker will automatically create a PDF of that page (the current record that is being browsed in a specific layout) and email the PDF as an attachment through FileMaker to all of the recipients listed in the first sentence of this paragraph.  People using Macs and PCs will be using this feature.  In addition, they are accessing the FileMaker database over the internet and they are using FileMaker.

                        

                      • 8. Re: Using Save ad PDF script step with a sub-summarized letter
                        TSGal

                        AAgraphics:

                         

                        Thank you for your post.

                         

                        I just answered your similar post.  Please see:

                         

                        http://forum-en.filemaker.com/fm/board/message?board.id=FM-en-4&message.id=26807

                         

                        If the above script isn't working correctly for you, what problems are you encountering?

                         

                        TSGal

                        FileMaker, Inc. 

                        • 9. Re: Using Save ad PDF script step with a sub-summarized letter
                          djckai
                            

                          Sorry to drag up an old thread, TSGal just wondering about your code you gave (brilliant by the way because I was needed the same and couldn't work it out).

                           


                          TSGal wrote:

                          laneystewart:

                           

                          Thank you for the clarification.

                           

                          Yes, the script I gave you was to print a page for each record.  If you want to modify it so you print a page for each grouping of records, then change the script to:

                           

                          Sort Records [ Restore ; No Dialog ]

                          Go to Record/Request/Page [First]

                          Loop 

                             Set Variable [ $key ; <key field for grouping> ]

                             Save Records As PDF [ No dialog ; "File" & $page & ".pdf" ; Records being browsed ; page range 1 to 1 ]

                             Loop

                                Omit Record

                                Exit Loop If [ <key field for grouping> ≠ $key

                             End Loop

                             Exit Loop If [ Get (FoundCount) = 0 ]

                          End Loop 

                           

                          -------------------

                           

                          This will print each page separately, assuming you have a sub-summary that begins on a page break.

                           

                          TSGal

                          FileMaker, Inc. 

                           


                           

                          Now this obviously just prints the first page each time and takes out the grouping that has just been printed. What if the grouping runs onto several pages? For example if you were doing an invoice run and the invoice for a few clients took up two pages. Wouldn't this code just print the first page of the invoice only?

                           

                          This isn't a problem I have at the moment but I can see this code being very useful for a few things and just want to check any limitations I'd have to look at.

                           

                          Cheers 


                          • 10. Re: Using Save ad PDF script step with a sub-summarized letter
                            TSGal

                            djckai:

                             

                            Thank you for your post.

                             

                            I apologize for the confusion.  In the example above I assumed it was one record per page.  If your layout is multiple pages, then the resulting PDF file will display multiple pages.  The maximum layout size is 110 inches, which is 10 pages of 8-1/2 by 11 inches.

                             

                            TSGal

                            FileMaker, Inc. 

                            • 11. Re: Using Save ad PDF script step with a sub-summarized letter
                              carrolljd
                                

                              TSGal, I am still confused.  I have reports with  leading subsummaries, body of more than one record, trailing subsummaries.  My sort works.  I need to create one PDF for each key, in this case client, and email it off to them.  I am confused by the printing of one page and then the omission of a single record.  I am also concerned that my PDFs could easily be 20 pages long. 

                               

                              I am clearly not understanding something.  I would appreciate a push in the right direction.

                               

                              Thanks,

                               

                              Jane

                              • 12. Re: Using Save ad PDF script step with a sub-summarized letter
                                philmodjunk
                                  

                                In your case, a script that works like this should do what you need:

                                 

                                Find all records for one client

                                Save as PDF

                                Email the PDF

                                 

                                Repeat for the next client.

                                 

                                How you "find all records for one client" depends on your database design.

                                One way is to use Replace field contents to "mark" each client's records after they are emailed, then you can loop your script as follows:

                                 

                                Loop

                                  #find all clients not yet emailed

                                  Enter Find Mode []

                                  Set Field [YourTable::Emailed ; "="] // find all records where "emailed" is empty //

                                  Set Error capture [on]

                                  Perform Find []

                                  Exit Loop If [ Get ( FoundCount ) = 0 /* all emails sent */]

                                  #find just one client

                                  Set Variable [$ClientID; value:  YourTable::ClientID ]

                                  Enter Find Mode []

                                  Set Field [ YourTable::ClientID; $ClientID]

                                  Perform Find []

                                  Sort[restore] //Specify sort order requried for your summary report//

                                  Save as PDf...

                                  Send Email...

                                  # Mark the records

                                  Replace Field Contents [No dialog; YourTable::Emailed ; 1 ]

                                End Loop

                                # Erase the mark so you can do this again later

                                Replace Field Contents [No dialog; YourTable::Emailed ; "" ]

                                 

                                That's the basic idea.

                                 

                                One caution: Replace field contents shouldn't be used in this way if the records being modified by it might be locked by other users on your network. It's best for single user files or for in a script run after hours when there are no other users editing records.

                                • 13. Re: Using Save ad PDF script step with a sub-summarized letter
                                  carrolljd
                                    

                                  Phil, thank you for replying.  I guess I was overthinking things.  I am going to use GTRR and go from there.  I appreciate the time you took to write out the script because that is not my strength.

                                   

                                  Thanks again,

                                   

                                  Jane

                                   

                                  • 14. Re: Using Save ad PDF script step with a sub-summarized letter
                                    philmodjunk
                                      

                                    If you use GTRR, make sure you know its undocumented limitations--some of them can have catastophic consequences if you don't script accordingly:

                                     

                                    Go To Related Records is a very useful tool, but which is very poorly documented. To learn more about GTRR, click the following link:

                                    The Complete Go To Related Record

                                    1 2 Previous Next