function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shakila Gshakila G 

Loop Item Not displaying in My Visualforce Page

Hi All,

I have a product data  in  Quote line Item 

Product1
Product 2
Product 3

Based on this product i have to fetch a dispatch Check list for Each Product

When am trying display all the checklist together in Visulal Force Page.. I can able to see only one product Checklist.

Am unable to get all Checklist togther as a one Checklist? Kindly Guide me on this

My VF Page :
<apex:page renderAs="PDF" standardController="Project__c" extensions="Dispatch_Workorder_Checklist" applyBodyTag="False" ShowHeader="False"  applyHtmlTag="False">
<html>
  <head>
    <style>
        @page {
            
            margin-top: 2cm;
            margin-bottom: 2cm;
            margin-right:1CM;
             margin-Left:1CM;
              padding: 5px;
              
            @top-center {
                content: element(header);
            }
            @bottom-left {
                content: element(footer);
            }
        }

        div.header {
            width: 100%;
            padding: 5px;
            position: running(header);
        }
        div.footer {
            display: block;
            padding: 5px;
            position: running(footer);
        }
        .pagenumber:before {
            content: counter(page);
        }
        .pagecount:before {
            content: counter(pages);
        }
        div.content {
             border: 1px solid black;
             padding: 5px;
            width: 100%;
        }        
    </style>
</head>

 <!-- ==== Header=== -->
  
          <div class="header" >               
                <p align="center"><b>Dispatch Check List</b></p>
           </div>
 <!-- ==== Header=== -->

<!-- ==== Product Deatils=== -->
    <apex:outputText style="page-break-Before: Avoid; white-space:nowrap" > 
   
    <div class="Content" style="position:absolute; width:100% white-space:nowrap">

    <table style="font-size:13px;font-face:Arial;page-break-inside: avoid;white-space:nowrap " border="1" rules="cols" cellspacing="0" width="100%" cellpadding="0" >
         
            <tr  height="30" width="100%" style="font-family: sans-serif; white-space:nowrap;font-weight: bold; font-size: 10pt;">
                            <th align="center">Sl.No</th>
                            <th align="center">Required Material Name</th>
                            <th> Product Name</th>
                            <th>Quantity</th>  
            </tr>            
                           <apex:variable value="{!0}" var="icount" />
                           <apex:repeat value="{!listdisprod }" var="line">
                           <apex:variable value="{!icount+ 1}" var="icount" />
           <tr> 
                            <td style="text-align:center; " border-style="solid;"  width="10%"  >{!icount}.</td>  
                            <td width="10%" align="center">{!line.Name}</td>
                            <td width="10%" align="center"><apex:outputField value="{!line.Product__c}"/> </td>
                            <td width="10%" align="center">{!line.Quantity__c }</td>
                                    
           </tr>
                 
          </apex:repeat>
         
                    
     </table>
    </div>

</apex:outputText>                         
         
   
</html>
</apex:page>


My Apex Clas:
public class Dispatch_Workorder_Checklist {
public Project__c CPWR {get;set;}
list<OpportunityLineItem> listlinitem = New List<OpportunityLineItem>();
list<Dispatch_Product_Checklist__c> listdisprod = New List<Dispatch_Product_Checklist__c>();
public list<Dispatch_Product_Checklist__c > getlistdisprod ()
{
Return listdisprod ;
}



    public Dispatch_Workorder_Checklist(ApexPages.StandardController controller) {
    
    CPWR=[select ID,Name,Opportunity__c from Project__c  where ID=:ApexPages.CurrentPage().getParameters().get('Id')];
    listlinitem =[select ID,Product2Id from OpportunityLineItem where OpportunityID=:CPWR.Opportunity__c  ];
    listdisprod =[select ID,Name,Product__c,Quantity__c from Dispatch_Product_Checklist__c where Product__c=:listlinitem[0].Product2Id ];    
  
    }

}

Out to get all product checklist together as one page in VF

Thanks,
Shakila
 
Best Answer chosen by shakila G
Bhargavi TunuguntlaBhargavi Tunuguntla
Hi 

Here you are only fetching for the first record in the List:
 
listdisprod =[select ID,Name,Product__c,Quantity__c from Dispatch_Product_Checklist__c where Product__c=:listlinitem[0].Product2Id ];
 
listlinitem =[select ID,Product2Id from OpportunityLineItem where OpportunityID=:CPWR.Opportunity__c  ];
Set<Id> ProductId=new Set<Id>();
for(OpportunityLineItem  oppLineItem :listlinitem )
{
ProductId.add(oppLineItem .Product2Id );
}
    listdisprod =[select ID,Name,Product__c,Quantity__c from Dispatch_Product_Checklist__c where Product__c in: ProductId ];

This might be useful .Please try the code.

Thanks.