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

  • shariq

    Member
    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:form>
    <apex:pageBlock>
    <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:commandLink>
    <br/>
    <apex:pageBlockTable value = "{!accList2}" var="acc2" columns="3" Id="pb">
    <apex:column value = "{!acc2.Description}"/>
    <apex:column value = "{!acc2.Name}"/>
    </apex:pageBlockTable>
    </apex:repeat>
    </apex:pageBlock>
    </apex:form>
    </apex:page>

     

    Hope this Helps.