You need to sign in to do that
Don't have an account?
Azusfdc
My requirement is when ever I am selecting the date range it should display 3 objects records. Here Issue is its working one time only at first go! any body try this below is the code ?
public class Daterangefetch { public list<Account> alist{set;get;} public list<Contact> clist{set;get;} public list<Opportunity> olist{set;get;} public list<wrapperlist> allvalues{set;get;} public DateTime startDate{set;get;} public DateTime endDate{set;get;} public boolean abool{set;get;} public Daterangefetch(){ } public void refresh() { abool=true; } public void display() { if(startDate!=null && enddate!=null) { alist=[Select a.name,a.CreatedDate from account a where a.CreatedDate >: startDate and a.CreatedDate <:endDate ORDER BY a.LastModifiedDate limit 3]; clist=[Select c.name,c.CreatedDate from contact c where c.CreatedDate>:startDate and c.CreatedDate <:endDate ORDER BY c.LastModifiedDate limit 6]; olist=[Select o.name,o.CreatedDate from opportunity o where o.CreatedDate>:startDate and o.CreatedDate <:endDate ORDER BY o.LastModifiedDate limit 6]; if(allvalues==null) { allvalues=new list<wrapperlist>(); for(account a:alist) { wrapperlist w=new wrapperlist(a); allvalues.add(new wrapperlist(a)); } for(contact c:clist) { wrapperlist w=new wrapperlist(c); allvalues.add(new wrapperlist(c)); } for(opportunity o:olist) { wrapperlist w=new wrapperlist(o); allvalues.add(new wrapperlist(o)); } } }else{ Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'Please Select the Date and Time')); } } public class wrapperlist{ public account a{set;get;} public contact c{set;get;} public opportunity o{set;get;} public wrapperlist(account a) { this.a=a; } public wrapperlist(contact c) { this.c=c; } public wrapperlist(opportunity o) { this.o=o; } } }
<apex:page controller="Daterangefetch" docType="html-5.0"> <style> .sample{ border:5px solid #81F79F; } .all{ background-color:#AC58FA; width:600px; height:650px; border-radius: 2em; padding-left:20px; padding-right:30px; color:#FFFFFF; } .one{ background-color:#00BFFF; width:600px; height:80px; border-radius: 2em; padding-left:10px; color:#FFFFFF; } .two{ background-color:#00BFFF; width:600px; height:500px; border-radius: 2em; padding-left:10px; color:#FFFFFF; } </style> <apex:form > <div class="all"><br/> <apex:panelGrid width="600px"> <apex:pagemessages /> </apex:panelGrid> <div class="one"> <br/> <apex:outputText ><b>Start Date: </b> <apex:input type="datetime-local" value="{!startDate}"> </apex:input> </apex:outputText> <apex:outputText ><b>End Date: </b> <apex:input type="datetime-local" value="{!endDate}" > </apex:input> </apex:outputText> <br/><br/> <apex:commandButton value="Display" action="{!display}" style="margin-left: 7cm;" reRender="t1"/> <br/> </div> <br/> <div class="two"> <br/><br/> <center> <apex:outputPanel id="t1"> <apex:DataTable value="{!allvalues}" var="al" > <apex:column headerValue="Account,Contact,Opportunity"> <br/> {!al.a.name} {!al.c.name} {!al.o.name} </apex:column> <apex:column headerValue=". CreatedDate"> <br/> <apex:outputText value="{0,date,dd'/'MM'/'yyyy}"> <apex:param value="{!al.a.createddate}"/> </apex:outputText> <apex:outputText value="{0,date,dd'/'MM'/'yyyy}"> <apex:param value="{!al.c.createddate}"/> </apex:outputText> <apex:outputText value="{0,date,dd'/'MM'/'yyyy}"> <apex:param value="{!al.o.createddate}"/> </apex:outputText> </apex:column> </apex:DataTable> </apex:outputPanel> </center> </div> </div> </apex:form> </apex:page>
First, I think you could use a single query on the Opportunity record, pulling in both the Contact and Account info through relationships. Then your "alllvalues" list would just contain all those Opportunity records. In your VF page, you could then display the Opportunity CreatedDate , the OpportunityContactRole record createddates (if you're using OCRs that is), and the Account created date.
In other words, you need to figure out how you want to display the data and fix your wrapper class.