+ Start a Discussion
Michael Haddad.ax365Michael Haddad.ax365 

Linking to Record in PageBlockTable


I assume this is simple enough, but don't want to waste time figuring it out.  I'm trying to render the Name of a Record as a link to the Record in a column of a pageBlockTable.

I'm using this syntax currently:

<apex:column headerValue="Name">
      <apex:outputLink value="{!lead.Id}">{!lead.Name}</apex:outputLink>

 Supposing I'm on a na2.salesforce.com, this will output the link as https://na2.salesforce.com/apex/00Q4000000HA9xUEAT.  Obviously I don't want the /apex/ in the URL.  I know I want to use the current server as the value in outputLink and the Record ID as a param, but how do I merge in the URL of the current server?

You need to use a / to create a relative link

<apex:outputLink value="/{!lead.Id}">{!lead.name}</apex:outputLink>

 but you should be using $Action, which will always find the correct view URL (very helpful for when your view page is overridden).

So instead, do something like this:

<apex:outputLink value="{!URLFOR($Action.Lead.View, lead.id)}">{!lead.name}</apex:outputLink>


Message Edited by jwetzler on 07-31-2008 11:19 AM
I wanted to achieve the similar functionality where I want to have a hyperlink in the pageblock so that lin is generated dynamically at runtime. When i am adding the link as outputlink is does not show up in my column.
Below is the same if you can help me out, would be greatly appretiated.
<apex:pageBlockTable value="{!Campaigns}" var="cmp">                                       
                   <apex:column value="{!cmp.ExtnName}"  width="10%" >
                     <apex:facet name="header" >Description</apex:facet>
                   <apex:outputLink value="/{!cmp.ExtnName}"></apex:outputLink>
Can you tell me what is incorrect here.
You have to put it in your column component if you want it to show up in your column.
Lukasz PiziakLukasz Piziak
I have a similar problem. Maybe since this issue is posted someone will help me?

My code is:
<apex:page standardController="SCMC__Production_Order__c" sidebar="false" showheader="true" recordSetVar="SCMC__Production_Order__c" extensions="TestExtension,TestExtension2">

<META http-equiv="refresh" content="60"/>

<apex:form >
<apex:pageBlock rendered="True" title="Production Orders">
<apex:pageBlockSection title="Production Orders to Fill">
<apex:pageBlockTable value="{!objlist}" style="width:1220px" var="item">
<apex:column style="width:100px" headerValue="Production Order No." value="{!item.name}"/>
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>

Unfortunately the production order record name is not as link which I can click and open. 
Below you can see the screenshot where you can observe that Sales Order No is as a link.

thank you for any help.

User-added image
Praveen Venkata BPraveen Venkata B
Hey Lukasz Piziak,

You can use something like below:
<apex:column headerValue="Notes" width="67%">
    <apex:outputLink value="/{!mcn.ID}"> 
        <apex:outputText value="{!left(mcn.body,25)}">

Praveen Venkata.
Becky Miller 10Becky Miller 10
How can I see just the My Open cases within the VF

<apex:page standardController="Case" recordSetVar="Case" tabstyle="Case" sidebar="false" showHeader="false"  >
<apex:pageBlock >
<apex:pageBlockTable value="{!case}" var="a" rows="50" >
<apex:column headerValue="Case Number" width="67%">
    <apex:outputLink value="/{!a.CaseNumber}">
     <apex:outputText value="{!a.CaseNumber}">
<apex:column value="{!a.Priority}" />
<apex:column value="{!a.Status}" />   
Praveen Venkata BPraveen Venkata B
Hello Becky Miller,

You can use a extension in which query the cases that you want to display and use that query variable in pageblocktable's value attribute.

Praveen Venkata.