1 2 Previous Next 25 Replies Latest reply on Feb 5, 2017 2:49 PM by techxedu

    multiple records per ID, save each to PDF

    techxedu

      Greetings!

       

      Having difficulties saving a "multiple record per student" layout into a separate PDF report for each student. Works well creating one huge PDF when "saved as PDF" from the preview mode but I also need to parse out the PDF to each student and that is where I would like to automate and having trouble. Here's what I have setup thus far:

       

      1) Table has multiple records per student

       

      2) Layout has these parts defined in the layout:

      - "sub-summary (leading)" with page break before occurrence ... this part has report title, student name, etc;

      - "body" part shows multiple records per student;

      - "sub-summary (trailing)" has a calculated fee total per student;

      - "trailing grand summary" shows grand total of all student fee summed up;

      - "footer".

       

      The current script looks like this:

      Go to Record/Request/Page [ First ]

      Loop

      Set Variable [ $IDStudent ; Value:Table::STUDENTID ]

      Set Variable [ $NameFamily ; Value:Table::LAST ]

      Set Variable [ $PDFFileName ; Value:$IDStudent & " " & $NameFamily" & ".pdf" ]

      Set Variable [ $DesktopPath ; Value:Get(DesktopPath) & "Folder1" & $PDFFileName ]

      Go to Related Record [From table: “Table”; Using layout: “consolidated report” (Table) ] [ Show only related records ; Match found set ]

      Save Records as PDF [ File Name: “$DesktopPath” ; Records being browsed ] [ Restore; No dialog ]

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

      End Loop

       

      When the script is run, it creates a separate PDF for each student but the content is all the same the consolidated report and not only that sutdent's report shown in the file name. Which makes me think that it is properly looping and picking up the student name to create the unique file name of the PDF but I must be missing a command and/or the options for the "Go to Related Record" or "Save Record as PDF" are not quite right.

       

      Any help/pointers/advice will be greatly appreciated. Thank yoU!

        • 1. Re: multiple records per ID, save each to PDF
          twelvetens

          You've got a GTRR step within your loop there, which means that within each iteration of the loop Filemaker is going to try and traverse that relationship, which seems a little odd.

           

          Could you provide more detail on what that script step does?

           

          Typically I'd collect all of the records I want to output to PDF first, and then loop through them creating PDF's as required...

          • 2. Re: multiple records per ID, save each to PDF
            philmodjunk

            I think that you just need to remove the "match found set" option.

            • 3. Re: multiple records per ID, save each to PDF
              techxedu

              Thank you for chiming in. I'm a novice with filemaker - started using about a year and a half ago - so I'm still learning.

               

              As far as the script ... so previously I was just using the GUI & doing a save as that saved the individual reports (heading, body, footer) for each student & saving it to one big PDF file. Then going in and extracting each student report to it's own PDF (tedious).

               

              So I hoped to reuse the script I used for prior project, that project was one record per student with many fields in each record. I "thought" in this case of multiple records for each student I need to use GTRR command to pull all records pertaining to a student, use the layout to create the report, write PDF, advance to next student ... loop it until no more students.

               

              Of course as I type this I'm thinking maybe this is not the right "logic" ... to be frank I don't think I fully understand everything that goes in the background for the report writer portion of FMP ...

              • 4. Re: multiple records per ID, save each to PDF
                techxedu

                Thank you for chiming in. I tried running with the the "current record" option and even unchecking the "show only related records" option that the current two options are under; they produced the same result as writing out one big PDF with different filenames (just like what the GUI will produce).

                 

                As I wrote the reply to James, I'm now thinking I probably is misunderstanding what goes on behind the scenes thus making it more difficult than it should?

                • 5. Re: multiple records per ID, save each to PDF
                  keywords

                  A further thought. Does the GTRR take you to a different layout from where you started? If so, your script doesn't involve a return to the starting layout before moving to the next record. That seems messy to me and a potential problem.

                  • 6. Re: multiple records per ID, save each to PDF
                    techxedu

                    I will check that. In GTRR I set the layout but in case.

                     

                    I'm still wonder if I'm misunderstanding this thing. For example last night I was thinking if I just have to use lookup table that has unique IDs, then store that in the variable, GTRR using that variable, save pdf & then advance to the next record of unique IDs?

                    • 7. Re: multiple records per ID, save each to PDF
                      philmodjunk

                      To repeat:

                      you need to use show only related records, but WITHOUT the "match found set" option selected.

                       

                      If you have "match found set" specified, you get all records in the related table that are linked to ANY record in your current found set. That means you'd get the same set of records with each pass thru the loop.

                       

                      You also need to return to the original layout at the end of your loop before going to the next record.

                      • 8. Re: multiple records per ID, save each to PDF
                        techxedu

                        Thank you for the reminder.

                         

                        I have done the following:

                         

                        1) make sure the GTRR option of "show only related records" are selected. However the sub-selections are radio buttons if I enable this so I have it WITHOUT "match found set" which means "current record only" as it is a radio button. I use FMP12. Here's a screen shot:

                        Capture.PNG

                        2) I also added "Go to Layout [original layout]" at the end of the loop.

                         

                        Unfortunately above changes produced the same one big PDF (at least with the unique filenames based on student name & ID). I also tried putting the Go to Layout ahead of advancing to the next record but produced the same results ...

                         

                        Thank you for the continued dialogue ... feel closer as I must be not doing something right or missing another command (like going to original layout that I was missing earlier) ...

                        • 9. Re: multiple records per ID, save each to PDF
                          erolst

                          Make sure that the target layout is in fact based on a table occurrence that has the desired relationship to the main layout (where the loop executes). GtRR lets you select any layout that is based on the same table as the target TO ('Get related record from') - but not every selection will be (semantically) correct.

                           

                          Speaking of semantics: 'Table' is a really bad table occurrence name ...

                           

                          If you don't have FM Advanced to debug the script step by step, I'd suggest you activate the 'Show in new window' option of GtRR, followed by a Halt Script step.

                           

                          That lets you inspect the actual related set you arrive at, before the PDF export. If that set doesn't match what you expect, then something would seem to be wrong with the relationship.

                          1 of 1 people found this helpful
                          • 10. Re: multiple records per ID, save each to PDF
                            philmodjunk

                            Current record is correct. That refers to the current record of those that you are looping thru, not the records you want in your PDF.

                             

                            Go To Layout should not be the last step in your loop. It needs to come before your go to record step.

                            • 11. Re: multiple records per ID, save each to PDF
                              techxedu

                              Thank you for the advice on "Table" naming ... will change.

                               

                              The windows opened by Halt Script does look good but makes me wonder if the subsequent "save to PDF" command changes that because the saved PDF is the whole enchilada instead of one student (multiple records per student) ...

                               

                              feels like almost there ...

                              • 12. Re: multiple records per ID, save each to PDF
                                techxedu

                                Understood on the placement of Go To Layout and thank you for explanation on the selection under Show only related Records.

                                 

                                It must be something stupid I'm doing ...

                                • 13. Re: multiple records per ID, save each to PDF
                                  BruceRobertson

                                  It might help to show us your revised script.

                                  • 14. Re: multiple records per ID, save each to PDF
                                    techxedu

                                    Yes, below is copy & paste - thank you! I haven't changed the table name yet.

                                     

                                    The Halt Script show the right layout in the other window but probably something happens when it reaches Save Records as PDF ... a novice guess.

                                     

                                    Go to Record/Request/Page [ First ]

                                    Loop

                                    Set Variable [ $IDStudent ; Value:Table::STUDENTID ]

                                    Set Variable [ $NameFamily ; Value:Table::LAST ]

                                    Set Variable [ $PDFFileName ; Value:$IDStudent & " " & $NameFamily & ".pdf" ]

                                    Set Variable [ $DesktopPath ; Value:Get(DesktopPath) & "FOLDER1" & $PDFFileName ]

                                    Go to Related Record [ From table: “Table”; Using layout: “consolidated report v1.12” (Table) ]

                                    [ Show only related records ; New window ]

                                    Halt Script

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

                                    [ Document - Compatibility: Acrobat 7 and later ]

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

                                    [ Security - Password to print/edit; Printing: High Resolution ; Editing: Not Permitted ; Enable Screen Reader ]

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

                                    [ Restore; No dialog ]

                                    Go to Layout [ original layout ]

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

                                    End Loop

                                    1 2 Previous Next