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
RishavRishav 

how to convert a record into a link and show the detail page of that record after clicking on record

How to convert a record into the link in visualforce pages and when i click on that it should redirected to the detail page of that record.
suppose that i am  having a visualforce page and i am fetching the account record in that page like below :
name     industry             site                           location
---------------------------------------------------------------------
ram          IT                     ram.com                  Newyork  -      1st record
Bell          Education      bell.com                   Alaska    -        2nd record

now every record should be as a link in visualforce page and when i click on that record it should show the detail page of tha record. please help 
Best Answer chosen by Rishav
Grazitti TeamGrazitti Team
Hi,

I assume that you are using either pageblocktable/datatable to render these values in the form of a table. If it is so, then you can simply change the first column i.e. name  with the tags similar to given below:

<apex:column style="text-align:center;">
          <apex:facet name="header">Name</apex:facet>
          <apex:commandLink action="{!RedirectToPage}" value="{!var.name}" id="theCommandLink">
           <apex:param name="RecordId Id" value="{!var.Id}" assignTo="{!RecordId}"/>
          </apex:commandLink>
</apex:column>

Here RedirectToPage is controller method which will be used to redirect to new page as given below:

public string RecordId{get;set;}
public pagereference RedirectToPage()
{
pagereference pageref = new pagereference('/'+ RecordId);
pageref.setRedirect(true);
return pageref;
}

Please let me know if you need any other help on this.

--
Regards,
Grazitti Team
Web: www.grazitti.com

All Answers

Sergey AlexandrovSergey Alexandrov
You needs setup layout for this page and choose link for display content
Grazitti TeamGrazitti Team
Hi,

I assume that you are using either pageblocktable/datatable to render these values in the form of a table. If it is so, then you can simply change the first column i.e. name  with the tags similar to given below:

<apex:column style="text-align:center;">
          <apex:facet name="header">Name</apex:facet>
          <apex:commandLink action="{!RedirectToPage}" value="{!var.name}" id="theCommandLink">
           <apex:param name="RecordId Id" value="{!var.Id}" assignTo="{!RecordId}"/>
          </apex:commandLink>
</apex:column>

Here RedirectToPage is controller method which will be used to redirect to new page as given below:

public string RecordId{get;set;}
public pagereference RedirectToPage()
{
pagereference pageref = new pagereference('/'+ RecordId);
pageref.setRedirect(true);
return pageref;
}

Please let me know if you need any other help on this.

--
Regards,
Grazitti Team
Web: www.grazitti.com
This was selected as the best answer
k sfdck sfdc
HI,
           In above record detail page how to display customly?