Activity Forums Salesforce® Discussions Can we get value of a particular field of object on a link in Salesforce?

  • shariq

    August 21, 2017 at 2:03 pm

    Hi Shubham,

    Apex Controller:-

    public class AccountNameLink
    public List<Account> accList {get;set;}
    public List<Account> accList2 {get;set;}
    public String linkId{get;set;}
    public AccountNameLink()
    accList = [SELECT Name FROM Account LIMIT 100];
    linkId = '';
    accList2 = new List<Account>();
    public void showAccounts()
    accList2 = [SELECT Name, Description FROM Account WHERE Id =:linkId];

    Apex Page:-

    <apex:page controller="AccountNameLink">
    <apex:repeat value = "{!accList}" var ="acc" >
    <apex:commandLink value="{!acc.Name}" action ="{!showAccounts}" reRender="pb">
    <apex:param value="{!acc.Id}" Name="Account Id" assignTo="{!linkId}"/>
    <apex:pageBlockTable value = "{!accList2}" var="acc2" columns="3" Id="pb">
    <apex:column value = "{!acc2.Description}"/>
    <apex:column value = "{!acc2.Name}"/>


    Hope this Helps.



  • Parul

    September 16, 2018 at 3:27 pm


    <apex:pageBlock >
    <apex:commandButton value="Click" action="{!main}" reRender="one"/>
    <apex:pageBlockSection id="one">
    <apex:pageBlockTable value="{!accs}" var="a">
    <apex:column headerValue="Account hyperlink">
    <apex:outputlink value="/{!a.Id}">{!a.Name}</apex:outputlink>
    <apex:column value="{!}"/>
    <apex:commandButton value="Click" action="{!main}" reRender="one"/>



Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos