AnsweredAssumed Answered

Printing portals with and without records

Question asked by NaturSalus on Dec 16, 2013
Latest reply on Dec 16, 2013 by philmodjunk


Printing portals with and without records


     As already mentioned in another of my posts ( )
     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.
     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:
     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.
     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
     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?