7 Replies Latest reply on Dec 16, 2013 10:44 AM by philmodjunk

    Printing portals with and without records

    NaturSalus

      Title

      Printing portals with and without records

      Post

           Hello,
            
           As already mentioned in another of my posts (http://forums.filemaker.com/posts/987d8213c9 )
            
           How to print one portal has already been detailed in this Forum: 
            
           The way to print the records displayed in a portal is to build a layout based on the child table that “owns” the records in the portal, and do your printing there.
            
           The information from the parent record can be in the header or subsummary part.
            
           The information from the child record should be in the body part.
            
            
           Using this approach I can print the records displayed on a portal but this approach fails when the portal doesn't have any records.
            
      Fields
            
           There is just the Item table with the following fields:
            
            
           __kp_Item (number)
           _kf_ItemType (number)
           _kf_ParentItem (number)
           ItemHierarchy (number)
           ItemName (text)
           ItemType (text)
            
            
      Record hierarchy
            
           Each Item record has a hierarchy that depends on the type of Item.
            
           The Item record hierarchy is established through a conditional value list.
            
           Although an Item can be anything (a member of a phylogenetic tree; a part in a BOM; members of a company's management structure; etc) let's imagine imagine that an item is a document.
            
           Let's suppose that there is the following relationship between Item type and Item hierarchy:
            
           ItemType-----------------------------Hierarchy
           Manual------------------------------------1
           Procedure--------------------------------2
           Working Instruction--------------------3
           Form-------------------------------------- 4
            
           Parent → Child relationship
            
            
           By “child” document I mean a document related to the current (parent) document that has a lower hierarchy.
            
           The parent → child relationship among the Item records is established through the following relationships:
            
           ItemTO::__kp_Item = ItemToChildItemTO::_kf_ParentItem
            
           ItemTO::_kf_ParentItem = ItemToParentItemTO::__kp_Item
            
           The children items of the current item record is displayed on a portal to the ItemToChildItemTO. So the number of child records on the portal can be:
            
             
      •           nil child documents
      •      
      •           one child document
      •      
      •           several children documents.
            
      Layouts
            
           I have two layouts:
             
      •           the Item_Detail layout based on the ItemTO is used to enter and display the item records
      •      
      •           the Child_Report layout based on the  ItemToChildItemTO is used to print the item records
            
           The Item_Detail layout has a portal to the ItemToChildItemTO that displays the child Item records for the current Item record. 
            
           Item records are printed through the Print button that triggers the Print script.
            
      Print script:
            
           # Go to the report layout
           Enter Browse Mode
           Go to Related Record [ From table: “DocumentToChildDocument” ; Using layout: “Document Report on Child” (DocumentToChildDocument) ] [ Show only related records ]
           Go to Layout [ “Document Report on Child” (DocumentToChildDocument) ]
           # Record printing
           Enter Preview Mode
           Print [ Records being browsed ; All Pages; Orientation: Portrait ; Paper size: 8,5" x 11" ]
           [ Restore: Samsung ML-2010 Series ]
           # Go to original layout
           Adjust Window [ Restore ]
           Go to Layout [ original layout ]
           Enter Browse Mode
           Unsort Records
            
            
           The Child_Report layout has the following structure:
            
           On the layout's header part there are the following fields:
            
             
      •           Item::ItemType
      •      
      •           Item::ItemName
            
           On the layout's body part there is the following field: ItemToChildItemTO::ItemName
            
      Goal
            
           My purpose is to be able to print the name of each item record as well as the names of its children item records shown on a portal. I can do it when the current item record has children item records displayed on the portal. However, I can't print out am item record without any children item records displayed on the portal. In this case, what I get is the previous item record that has children records on the portal.
            
            
           So let's imagine that:
            
           the item record # 4 has the following data:
             
      •           Item Name: Working Instruction 1
      •      
      •           Children items: Working Instruction 1 Form 1
            
           the item record # 5 has the following data:
             
      •           Item Name: Working Instruction 1 Form 1
      •      
      •           Children items: none
           If I run the Print script from the record #4 I get what is expected:
            
             
      •           Item Name: Working Instruction 1
      •      
      •           Children items: Working Instruction 1 Form 1
            
           However, if I run the Print script from record # 5 I don't get what is in this record but what is in the record # 4 instead.
            
            
            
           My question is what do I have to do to be able to print records that have a portal, no matter whether there are or not portal records in it?
            
           Thanks,
            

        • 1. Re: Printing portals with and without records
          philmodjunk

               While printing from a layout based on the portal's layout is a very good and flexible object for many systems, it doesn't work for every possible data model.

               Sometimes you have to balance the pros and cons of some less than optimum choices for how to get the needed report.

               Option 1: Use a layout based on the parent table and use portals to show the related data. You can make the portal's many rows tall and set them to slide up and re-size in order to get the results that you want. The "cons" to this approach are that you have significant limitations if you need data inside a portal row to slide/re-size and you can also have issues with page breaks.

               Option 2: Sometimes you can add "dummy" records to your tables so that there is always at least one record in the child table. This record can be flagged with a special value in a "flag" field such that it is ignored/hidden/omitted in your reports and summary calculations. You can probably spot the "cons" to this option right away--you have to put in a fair amount of design effort in scripts, calculations and relationships to automatically generate those "dummy" records and to keep them from producing an error in your reporting.

               Option 3: And if all else fails there are cases where the best option is to set up a temporary "report" table where you import copies of your data from the related tables. This produces a noticeable delay when you click a button to produce your report and and require very complex scripting and layout designs, but is also sometimes the only way to really get the report you need.

          • 2. Re: Printing portals with and without records
            NaturSalus

                 Hello Phil,

                 Thanks for your input. 

                 Option 1 is the easiest one to implement and I have used it in some cases where it was feasible. In my current project, it is not possible since there is no way to know the maximun number of child records that a parent record can have.

                 This leaves me with options 2 and 3. I will google to get some additional insight about option 3.

                  

            • 3. Re: Printing portals with and without records
              philmodjunk

                   Option 1 may still work. The trick is to specify very large portals and to include a safety check, such as a calculation field that counts the number of related child records so that you can see a warning message if the total child records exceeds even that maximum.

                   Option 3 can be a real nightmare so I wouldn't go there unless I truly felt that no other option will get the job done.

              • 4. Re: Printing portals with and without records
                NaturSalus

                     Hello again,

                Option 3 can be a real nightmare so I wouldn't go there unless I truly felt that no other option will get the job done.

                Glad you put me out of the muddy track. I don't know if you meant something along the virtual list approach... But since I am an "aficionado" (layman) concerning programming I haven't been able  to put it into practice the virtual list concept.

                      

                Option 1 may still work. The trick is to specify very large portals and to include a safety check, such as a calculation field that counts the number of related child records so that you can see a warning message if the total child records exceeds even that maximum.

                     Option 1 is more in the realm of my capabilities.

                     Just correct me if I am wrong, but  is it true that the portal on the layout used to enter the data (the Item_Detail layout) must have and show the same number of rows that the portal on the layout used to display the data in the report (the Child_Report layout)?

                     If the answer is yes, how do I do to prevent it to look aesthetically weird?

                      

                      

                      

                • 5. Re: Printing portals with and without records
                  philmodjunk
                       

                             is it true that the portal....

                       This is not true. You can set up a 5 row portal on your data entry layout with a scroll bar and set up a 50 row portal on the report layout from which you print, preview and/or save as PDF.

                  • 6. Re: Printing portals with and without records
                    NaturSalus

                    This is not true. 

                         Great news! Then, I can handle this.

                         In case I don't bother you with another question before Christmas time:

                         Merry Christmas and a Happy New Year 2014  to you and your family!

                         José (a.k.a natursalus)

                    • 7. Re: Printing portals with and without records
                      philmodjunk

                           And to you and yours as well!