7 Replies Latest reply on Jun 9, 2012 1:08 PM by mikethecreative

    Summary Report - Multiple Product Types

    mikethecreative

      Title

      Summary Report - Multiple Product Types & Layouts

      Post

      I have a database that sells various Product Types; Shirts, Pants, Jackets, etc. Each Product Type has various specifications that are unique to that Product Type. I want to created a Summary Report that lists out each Product Type (or "Line Item") with it's various specifications in a multipage PDF.

       

      Example:

      Order #557

      LINE ITEM TYPE DESCRIPTION
      Item #1  Shirt  Blue
      Item #2  Jacket  Black
      Item #3  Shirt  White

       

      When I click my "Summary Report" button, I want the script to go to "Item #1" and realize that it is a "Shirt" (based off the Product Type) and go to "Layout - Shirt" and create a PDF with that ONE LINE ITEM and that ONE LAYOUT. Then, I'd like the script to go to "Item #2" and realize it is a "Jacket" and go to "Layout - Jacket" and create AND APPEND a PDF to the previous PDF, and so on with each additional line item. I hope that makes sense.

       

      I have created a Layout for each Product Type with it's own specifications, but the script I created doesn't seem to work; each "Layout" contains every Line Item in the Order. So for the above example, instead of the Summary Report being 3 pages long, it ends up being 9 pages long with each Line Item being represented on each Layout. I've tried so many combinations of different variables but nohting works.

       

      What am I doing something wrong? I've tried for hours and hours and my head is hurting. Heeeeelp...

      database.png

        • 1. Re: Summary Report - Multiple Product Types & Layouts
          GuyStevens

          I don't really understand exactly what you are trying to do here.

          You want a seperate page for every item, but what's on that page?

          Is it for all kinds of product information?

          Is this a sort of attachement to an actual invoice?

          Because the example you are giving is a very simple, basic sort of invoice based on the line items table.

          • 2. Re: Summary Report - Multiple Product Types & Layouts
            Sorbsbuster

            You could try this.  Have a print script that starts at your list layout.

            Go to Record [First]

            Loop

            If (ProductType = "Shirt" )

            Go to Layout "Shirt Specification" (a layout that only has the fields relevant for a shirt)

            Else If ( (ProductType = "Trousers" )

            Go to Layout "Trouser Specification" (a layout that only has the fields relevant for a pair of trousers)

            Else If [etc...]

            End If

            Print (set to print to pdf, current record only, append to existing pdf, no dialogue, etc)

            Go to Layout [Original layout] (## Not necessary, of course: I just think this works like my mind works)

            Go to Record [Next, exit after last]

            End Loop

            • 3. Re: Summary Report - Multiple Product Types & Layouts
              mikethecreative

              DaSaint- Yes, I want a separate page for each item, because Product Type has specific information that is only relevant to that product. For example, Shirt has length of sleeves, pockets, etc, whereas Pants have pant length, waist size, etc. And yes, it is a separate attachment to the Invoice.

              Sorbsbuster- That is almost exactly what my script looks like, but I'm still having the problem below.

               

              The issue I am having is that each page is using every Line Item instead of just one Line Item. So for the Line Item 1 (Shirt) it will go to the Shirt Layout and will make a page for Line Item 1 (Shirt), Line Item 2 (Jacket), and Line Item 3 (Shirt). It should only make a page for Line Item 1. After that, it will go to Line Item 2 (Jacket), go to the Jacket Layout and make a page for Line Item 1 (Shirt), Line Item 2 (Jacket), and Line Item 3 (Shirt) - again, duplicating all Line Items instead of just the 1 line item. So maybe its not my script, maybe it's my actual layout? I don't know.

              Thank you both so much for responses. Any help would be appreciated.

               

              ** Also, here is a photo of 2 of the Product Type pages. As you can see, they have different information that relates only to that particular Product Type.

              • 4. Re: Summary Report - Multiple Product Types & Layouts
                GuyStevens

                I don't know the details of your tables and fields but roughly speaking I would guess something like this:

                If you go to your Lineitems layout (invoice repot) you need to perforrm a find on the invoice ID to show only the line items for that invoice.

                Then you make your invoice as a PDF. I would suggest making a variable that determines the filename. I always store all my files automatically in a folder on the desktop and name tham by invoice date and client name.

                The reson for storing on the desktop is because that works on both Windows and Mac.  -  Get (DesktopPath)

                Then when your invoice pdf is made you loop trough the Lineitems one by one, set the Product ID as a variable, Use an IF statement in your script or a calculation with a case statement in another field to determine the layout you need to go to.

                Then in that layout you perform a find for your item using it's ID that we stored as a variable.

                Once found you create the pdf, append it to the existing pdf usinf the filename variable.

                You return to the lineitems table that's only showing the line items for your current invoice and you omit the record you have already saved.

                That way you automatically arrive at the next record and the loop repeats. (Set ProductId as variable, determine the layout, go there, perform the find, append, ...

                The loop ends when  Get (FoundCount) = 0

                Should work nicely.

                 

                If you need any help with the details let me know.

                • 5. Re: Summary Report - Multiple Product Types & Layouts
                  Sorbsbuster

                  Did you set the print script step to print 'Current Record only'?

                  • 6. Re: Summary Report - Multiple Product Types & Layouts
                    mikethecreative

                    DaSaint-

                    Thanks, I used some of those tips in the script.

                    • 7. Re: Summary Report - Multiple Product Types & Layouts
                      mikethecreative

                      Sorbsbuster-

                      I tried that and it worked. What's strange is that I tried that before and it would only print the first record. I think it's because I had it Open the Attachement immediately and it didn't append all the pages so I thought it wasn't working.

                      Thanks so much!