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
davidjbbdavidjbb 

VF Page variable loop + Apex Class

Hi Community,

I need the startDate and finishDate to loop for each "ClosedWorkorders" in the VF page, not sure what to do. Please note I need the format of the VF page the way it is. I am planning to download the VF page as it is.

 

I could've done {!wo.jbbfc2__Start_Date__c} but its in date time format, either way.. I'm going to need a solution for looping startDate and finishDate for other similar code in the future

 

At the moment it's only picking up the date of one ClosedWorkorders

 

VF Page

<apex:repeat value="{!ClosedWorkorders}" var="wo" id="foreachworkorder" >

{!startSales}
{!wo.jbbfc2__Account__r.Name},,,{!wo.jbbfc2__Account__r.ShippingStreet},,{!wo.jbbfc2__Account__r.ShippingCity},{!wo.jbbfc2__Account__r.ShippingState},{!wo.jbbfc2__Account__r.ShippingPostalCode},{!wo.jbbfc2__Account__r.ShippingCountry}
{NUMBEROFDETAILLINES},{!wo.Name},{!startDate},{!finishDate},{!totalAmount},{!freightAmount}
{!endSales}
{!blank}
<apex:variable var="count" value="{!1}"/>
</apex:repeat>

 Apex Class:

//Get Closed Work Orders between From and To Date
		public void setClosedWorkorders(){

		this.ClosedWorkorders = [Select Name, CreatedDate, jbbfc2__Start_date__c, jbbfc2__Finished_Date__c,
			jbbfc2__Account__r.Name, jbbfc2__Account__r.Id,  jbbfc2__Account__r.ShippingCity, 
        	jbbfc2__Account__r.ShippingStreet, jbbfc2__Account__r.ShippingState, jbbfc2__Account__r.ShippingPostalCode, 
      		 jbbfc2__Account__r.ShippingCountry
			from jbbfc2__workorder__c 
			where jbbfc2__Start_Date__c > :getFromDate()  and jbbfc2__finished_date__c < :getToDate() and jbbfc2__status__c ='Closed'];
		
		}



//Set the Start Date for each Work Order
		public void setStartDate(){
		for(jbbfc2__Workorder__c wo: getClosedWorkorders()){
		this.startDate= string.valueof((wo.jbbfc2__Start_Date__c).date());	//TODO change to month date year format
		}	
		}
		//Get the Start Date for each Work Order
		public string getStartDate(){
		return this.startDate;
		}
		
		public void setFinishDate(){
		for(jbbfc2__Workorder__c wo: getClosedWorkorders()){
		this.finishDate = string.valueof((wo.jbbfc2__Finished_Date__c).date());	//TODO change to month date year format
		}
		}
		
		public string getFinishDate(){
		return this.finishDate;
		}