0
<apex:page standardController="contact" recordSetVar="conList" sidebar="false" >
<apex:form>
<apex:pageBlock title="Contacts" >
    <apex:pageBlockButtons>    
            <apex:commandButton action="{!create}" value="New Contact" />
    </apex:pageBlockButtons>
        <apex:pageBlockSection>
            <apex:pageBlockTable value="{!conList}" var="con" >
                <apex:column headerValue="Action" >
                    <apex:outputLink value="{!URLFOR($Action.contact.Edit, con.id)}">
                        Edit 
                    </apex:outputLink>    
                </apex:column>
                <apex:column headerValue="Name" >
                    <apex:outputLink value="{!URLFOR($Action.contact.view, con.id)}"> 
                        {!con.name} 
                    </apex:outputLink>
                </apex:column>
                <apex:column value="{!con.phone}"/>
                <apex:column value="{!con.account.name}" onclick="{!}" />
            </apex:pageBlockTable>
        </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>    

I am trying to make the account column an output link in the same way i did for the contact name column. If this is not possible, what is the correct approach?

 <apex:column>
     <apex:outputLink value="{!URLFOR($Action.contact.account.view, con.id)}"> 
         {!con.account.name} 
     </apex:outputLink>
 </apex:column>
1

You were close with your solution. I believe the below code should show what you are looking for.

<apex:page standardController="contact" recordSetVar="conList" sidebar="false" >
<apex:form>
    <apex:pageBlock title="Contacts" >
        <apex:pageBlockButtons>    
            <apex:commandButton action="{!create}" value="New Contact" />
        </apex:pageBlockButtons>
        <apex:pageBlockSection>
            <apex:pageBlockTable value="{!selected}" var="con" >
                <apex:column headerValue="Action" >
                    <apex:outputLink value="{!URLFOR($Action.contact.Edit, con.id)}">
                        Edit 
                    </apex:outputLink>    
                </apex:column>
                <apex:column headerValue="Name" >
                    <apex:outputLink value="{!URLFOR($Action.contact.view, con.id)}"> 
                        {!con.name} 
                    </apex:outputLink>
                </apex:column>
                <apex:column value="{!con.phone}"/>
                <apex:column headerValue="Account Name">
                    <apex:outputLink value="{!URLFOR($Action.account.view, con.AccountId)}"> 
                        {!con.account.name}
                    </apex:outputLink>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

  • I am getting a runtime error Invalid parameter for function URLFOR – Mohit Joshi Jun 21 '17 at 16:20
  • Where are you using this code? – Dan Kowalski Jun 21 '17 at 16:21
  • i am using it same as you used in your code – Mohit Joshi Jun 21 '17 at 16:23
  • Sorry, I mean are you using it on a page layout or a related list, or a list view? – Dan Kowalski Jun 21 '17 at 16:23
  • in a page layout – Mohit Joshi Jun 21 '17 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.