10 Replies Latest reply on Nov 14, 2011 12:00 PM by RohanBarnett

    File naming with variable and email PDF records

    RohanBarnett

      Title

      File naming with variable and email PDF records

      Post

      I am hoping someone can help me with this as I seem to be going round in circles. I am trying to create a statement output to PDF from our accounts showing outstanding invoices and giving each PDF a unique name based on the customer number which is then sent to our email clent.
      Essentailly I can get both parts of the script to work OK independently but to display the records correctly in the PDF Preview has to be turned on and then the Variable ceases to work.

      I have attached a screen grab of one of the versions of the script. 

      Any advice would be much apprecaited.

      Rohan

      script.jpg

        • 1. Re: File naming with variable and email PDF records
          philmodjunk

          What is the purpose for entering preview mode?

          Your script saves to PDF one page of your previewed report at a time. It doesn't save one record at a time because you are in Preview Mode when you run. If one record = 1 page of your report, you should get the same results without entering preview mode.

          Looks like you need to modify this script so that it runs in browse mode so that go to record/request/page does a go to record action not a go to page action as it does in your current script.

          • 2. Re: File naming with variable and email PDF records
            RohanBarnett

            Thanks Phil

            Each page of the report pulls data from a number of invoice records if not in preview mode these are not displayed as one output PDF.

            • 3. Re: File naming with variable and email PDF records
              philmodjunk

              Each page of the report pulls data from a number of invoice records if not in preview mode these are not displayed as one output PDF.

              Please describe the design of your layout in more detail. It shouldnot be necessary to enter preview mode to do what you have here. Save Records as PDF with the current record option only generates a PDF from the current record and that should be something you can do from browse mode.

              Out of curiosity, what do you get when you run the current script? Do you get a file with the same or wrong customer number?

              • 4. Re: File naming with variable and email PDF records
                RohanBarnett

                No, file number is okay although I have just realised it was missing the .pdf

                The layout is as follows:

                Header: address, date etc.,

                Sub-summary by Contacts::Customer number (Leading)  - No content

                Body: invoice Number item description Amount etc

                Sub-summary by Customer No (Trailing)

                 

                All of which deisplays and prints fine in Preview mode but only as single records in browse mode.

                • 5. Re: File naming with variable and email PDF records
                  philmodjunk

                  In Browse Mode, select the View as List option and it should look fine. Even without this change, the PDF's created should look correct as they should replicate what you seen in preview mode, though you may have to specify the "records being browsed option" as that is the option Preview Mode attempts to replicate.

                  "missing the PDF" as in no PDF's are being created or....?

                  • 6. Re: File naming with variable and email PDF records
                    RohanBarnett

                    Unfortunately that doesn’t work, if I choose 'records being browsed" then it prints the lot.

                    missing pdf file extension.

                    Also the script is sending one blank email before each one with PDF attachement?

                    • 7. Re: File naming with variable and email PDF records
                      philmodjunk

                      Yes it "prints the lot" but you don't have to bring up all the records in one batch and then start saving as PDF. You can pull up one group of records at a time from within your loop.

                      The PDF extension can be included in your save as step if you write it like this:

                      "Nov Statement " & Contacts::Customer No & ".PDF"

                      Hmmm, what will you do for your December statement? Surely you don't plan on modifying your script each month?

                      • 8. Re: File naming with variable and email PDF records
                        RohanBarnett

                        Thanks for your suggestions.

                        Yes, the problem I am having is getting the each group to print as one pdf any suggeations as to the missing script strep/s in the loop?

                        I have the pdf exstension okay thanks and the current FileName is illustrative only will tidy all the rest i.e., reference month field once I have this script doing what it needs to do. I must have written and rewitten this script a hundred times and things get left off! 

                        • 9. Re: File naming with variable and email PDF records
                          philmodjunk

                          I don't know the structure of the tables, nor the design of your layout. If you have this table structure:

                          Invoices----<LineItems

                          You can perform a find on the invoices layout to bring up the set of invoices for which you wish to generate statements as PDF's. Then this script out line should show you how to save one PDF per invoice from the LineItems layout designed for printing invoices:

                          Go To record/request/page [first]
                          Loop
                             If [LineItems::InvoiceID //make sure there are line items records]
                                Go To Related Record [Show only related records; From table: LineItems; Using layout: "InvoicePrint" (LineItems)]
                                #Put your save as PDF and email steps here
                                Go To Layout [Invoices]
                             End If
                             Go To Record/Request/Page [next ; exit after last]
                          End Loop

                          • 10. Re: File naming with variable and email PDF records
                            RohanBarnett

                            Many thanks and much appreciated I will give ths a go and post how I get on.