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
SreejbSreejb 

Want to fetch records from custom objects and show in VF Page as per month and year

Hi all, 

I want to fetch recods from custom object time_entry__c and show in one VF page with condition month and year selected in vf page and same time it should retrive as per logged user records only need to show. I am new to salesforce please guys help on this

Regards
Sreejayabalajee

 
Nitin SharmaNitin Sharma
Hi
Use below vf page just change object name and desired field value.
For custom object use controller.
<apex:page standardController="Account"  extensions="Searchclass" tabStyle="User">  
  <apex:form > 
  <apex:sectionHeader title="User Global Search" subtitle="Result"/> 
  <apex:pageBlock >
      <apex:pageBlockSection columns="1">
          <apex:pageBlockSectionItem >
              <label>Quick Search</label>
              <apex:outputPanel >
                  <apex:inputText value="{!searchstring}" label="Input"/>
                  <apex:commandButton value="Search records" action="{!search}" reRender="accPgId" status="ajaxId"/>
                  &nbsp;<apex:actionStatus startText="Searching..." id="ajaxId"></apex:actionStatus>
              </apex:outputPanel>
          </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
  </apex:pageBlock>
  
  
    
     
   <apex:pageBlock title="Search Account Result" id="accPgId" >  
    <apex:pageblockTable value="{!acc}" var="a">  
      
     <apex:column headerValue="Name" >  
       <apex:outputlink >{!a.Name}</apex:outputlink>
     </apex:column> 
     <apex:column headerValue="Phone" >  
       <apex:outputlink >{!a.Phone}</apex:outputlink>
     </apex:column>
     
    </apex:pageBlockTable>     
   </apex:pageBlock>  

  </apex:form>  
 </apex:page>

Apex class
public with sharing class Searchclass {
  
   public list <Account> acc {get;set;}
 
   public string searchstring {get;set;} 
    string a;
   
   
    
   public Searchclass(ApexPages.StandardController controller) {
     
   }  
   public void search(){  
     if(searchstring != null && searchstring != '' ){  
     string searchquery='select Name, Phone from Account where Name like \'%'+searchstring+'%\'  LAST IN DAYS 30';  
    
     acc= Database.query(searchquery); 
     
     }
     }
     
    
   }


Thanks,
Nitin Sharma

 
SreejbSreejb
Hi Nithin

What u mention in code that is not working properly. Can you give some detail explanation.


Regards
Sreejayabalajee