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
ABHISHEK CHOPRAABHISHEK CHOPRA 

To show a detail page on click of the record

Hi EveryOne, 
Below is my Apex and VF code. What i want to acheive is when i click on the record displayed in the Page block section on a list of Account then the detail page of the same record is displyed under that section.


Apex Code:- 
public class c4{
list <Account> acts1;
list <Account> acts2;

public list <Account> getacts1()
{
return acts1;
}


public list <Account> getacts2()
{
return acts2;
}

public pagereference direct()
{

acts1 = [Select Name , Type , Industry , Phone from Account where type='Customer - Direct'];
 return null;
}

public pagereference channel()
{

acts2 = [Select Name , Type , Industry , Phone from Account where type='Customer - Channel'];
 return null;
}
 
 }





VF Code:-

<apex:page controller="c4" sidebar="false" >
<apex:form >
<apex:pageBlock title="Account Classification on click of a button">
<apex:pageblockSection id="a" >

<apex:commandButton value="Customer-Direct" action="{!direct}" reRender="a">
<apex:pageBlockTable value="{!acts1}" var="abc">
<apex:column value="{!abc.Name}"/>
<apex:column value="{!abc.Type}"/>
<apex:column value="{!abc.Industry}"/>
<apex:column value="{!abc.Phone}"/>
</apex:pageBlockTable>
</apex:commandButton>


<apex:commandButton value="Customer-Channel" action="{!channel}" reRender="a">
<apex:pageBlockTable value="{!acts2}" var="xyz">
<apex:column value="{!xyz.Name}"/>
<apex:column value="{!xyz.Type}"/>
<apex:column value="{!xyz.Industry}"/>
<apex:column value="{!xyz.Phone}"/>
</apex:pageBlockTable>
</apex:commandButton>


</apex:pageblockSection>
</apex:pageBlock>

</apex:form>  
</apex:page>
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Abhishek,

You can use the following method as the button action.
public PageReference redirectToDetail()
{
PageReference redirect = new PageReference('/' + objectId); 
return redirect;
}
 where objectId is the SF Id of an object. I hope it will be helpful.

Best Regards
Rahul Kumar