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
kittu9kittu9 

clicking command link have to display particular selected record id standard page from the vf page

<apex:page sidebar="false"  standardController="Business_Status_Report__c" extensions="BSRData"  tabStyle="Business_Status_Report__c">
<script>
 function setFocusOnLoad() {}
</script>
   <apex:form >
   <apex:outputText >From Date :</apex:outputText>
 
   <apex:inputField value="{!bsrObj1.Date__c}"/>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   
   <apex:outputText >To Date :</apex:outputText>
   <apex:inputField value="{!bsrObj2.Date__c}"/>
    <br/><br/>
   <apex:commandButton value="Generate Report" action="{!getData}"/><br/> <br/>

    <apex:pageBlock >
     <apex:pageBlockTable value="{!bsr1}" var="b">
       <apex:column headerValue="CreatedByName">
       <apex:outputLink >{!b.CreatedByName__c}</apex:outputLink>
      </apex:column>  
     
      <apex:column headerValue="BSR Name">
       <apex:outputLink >{!b.Name}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Account Name">
      <apex:outputLink  >{!b.Account__r.Name}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Main Contact">
      <apex:outputLink >{!b.Contact__c}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Date">
      <apex:outputText >{!b.Date__c}</apex:outputText>
      </apex:column>
      <apex:column headerValue="Status">
      <apex:outputText >{!b.Status_Update_Notes__c}</apex:outputText>
      </apex:column>
      <apex:column headerValue="Type">
      <apex:outputText >{!b.Type__c}</apex:outputText>
      </apex:column>
     </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:form>
</apex:page>

-------------------
public class BSRData  
{
  public List<Business_Status_Report__c> bsr1 { set; get; }
  public Business_Status_Report__c bsrobj1;
  public Business_Status_Report__c bsrobj2;
 
     public Business_Status_Report__c getBsrObj1()
    {
     if (bsrobj1 == null)
     {
      bsrobj1 = new Business_Status_Report__c();
      return bsrobj1;
     }
     else
       return bsrobj1;
    }
    
   public Business_Status_Report__c getBsrObj2()
    {
     if (bsrobj2 == null)
     {
      bsrobj2 = new Business_Status_Report__c();
      return bsrobj2;
     }
     else
       return bsrobj2;
    }

    public BSRData(ApexPages.StandardController controller) {
   
    }

 public List<Business_Status_Report__c> bsr { set; get; }
 public BSRData()
 {
 
 }
 public void getData()
 {
  if ( bsrobj1.Date__c != null && bsrobj2.Date__c != null)
   {
     
       Datetime dt = bsrobj1.Date__c;      
       Date dates = dt.date();       
    
       Datetime dt1 = bsrobj2.Date__c;    
       Date dates1 = dt1.date();
       

       if ( Date.valueOf(String.valueOf(dates)) > Date.valueOf(String.valueOf(dates1)) )
       {   
       
       }
      else
       {      
        System.debug('I am in else block');
       
        bsr1 = [SELECT CreatedByName__c,Account__r.Name,Name,Agency__c,BSR_Name__c,Contact__c,CreatedById,Date__c,Status_Update_Notes__c,Type__c FROM Business_Status_Report__c where CreatedDate__c >=: Date.valueOf(String.valueOf(dates)) and CreatedDate__c <=: Date.valueOf(String.valueOf(dates1)) order by CreatedById ];                
       }
    }
 }

 

By clicking the output link have to display particular record of that standard page. how to display that standard record page by clicking the command link can any one help on this.
}

Best Answer chosen by Admin (Salesforce Developers) 
Chamil MadusankaChamil Madusanka

Use following code. I changed the highlighted line.

 

<apex:page sidebar="false"  standardController="Business_Status_Report__c" extensions="BSRData"  tabStyle="Business_Status_Report__c">
<script>
 function setFocusOnLoad() {}
</script>
   <apex:form >
   <apex:outputText >From Date :</apex:outputText>
 
   <apex:inputField value="{!bsrObj1.Date__c}"/>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   
   <apex:outputText >To Date :</apex:outputText>
   <apex:inputField value="{!bsrObj2.Date__c}"/>
    <br/><br/>
   <apex:commandButton value="Generate Report" action="{!getData}"/><br/> <br/>

    <apex:pageBlock >
     <apex:pageBlockTable value="{!bsr1}" var="b">
       <apex:column headerValue="CreatedByName">
       <apex:outputLink >{!b.CreatedByName__c}</apex:outputLink>
      </apex:column>  
     
      <apex:column headerValue="BSR Name">
       <apex:outputLink value="/{!b.Id}" target="_blank">{!b.Name}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Account Name">
      <apex:outputLink  >{!b.Account__r.Name}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Main Contact">
      <apex:outputLink >{!b.Contact__c}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Date">
      <apex:outputText >{!b.Date__c}</apex:outputText>
      </apex:column>
      <apex:column headerValue="Status">
      <apex:outputText >{!b.Status_Update_Notes__c}</apex:outputText>
      </apex:column>
      <apex:column headerValue="Type">
      <apex:outputText >{!b.Type__c}</apex:outputText>
      </apex:column>
     </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:form>
</apex:page>

 

If you got the answer from this post, Please hit the Kudos button & mark the answer as solution, It might help others running to into similar problem in future.

All Answers

Chamil MadusankaChamil Madusanka

Use following code. I changed the highlighted line.

 

<apex:page sidebar="false"  standardController="Business_Status_Report__c" extensions="BSRData"  tabStyle="Business_Status_Report__c">
<script>
 function setFocusOnLoad() {}
</script>
   <apex:form >
   <apex:outputText >From Date :</apex:outputText>
 
   <apex:inputField value="{!bsrObj1.Date__c}"/>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   
   <apex:outputText >To Date :</apex:outputText>
   <apex:inputField value="{!bsrObj2.Date__c}"/>
    <br/><br/>
   <apex:commandButton value="Generate Report" action="{!getData}"/><br/> <br/>

    <apex:pageBlock >
     <apex:pageBlockTable value="{!bsr1}" var="b">
       <apex:column headerValue="CreatedByName">
       <apex:outputLink >{!b.CreatedByName__c}</apex:outputLink>
      </apex:column>  
     
      <apex:column headerValue="BSR Name">
       <apex:outputLink value="/{!b.Id}" target="_blank">{!b.Name}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Account Name">
      <apex:outputLink  >{!b.Account__r.Name}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Main Contact">
      <apex:outputLink >{!b.Contact__c}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Date">
      <apex:outputText >{!b.Date__c}</apex:outputText>
      </apex:column>
      <apex:column headerValue="Status">
      <apex:outputText >{!b.Status_Update_Notes__c}</apex:outputText>
      </apex:column>
      <apex:column headerValue="Type">
      <apex:outputText >{!b.Type__c}</apex:outputText>
      </apex:column>
     </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:form>
</apex:page>

 

If you got the answer from this post, Please hit the Kudos button & mark the answer as solution, It might help others running to into similar problem in future.

This was selected as the best answer
kittu9kittu9
Thank you so much Chamil. It is working now.
Chamil MadusankaChamil Madusanka

If you got the answer from this post, Please hit the Kudos button