Activity Forums Salesforce® Discussions 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.

     

     

  • Parul

    Member
    September 16, 2018 at 3:27 pm

    Hi

    <apex:pageBlock >
    <apex:pageBlockButtons>
    <apex:commandButton value="Click" action="{!main}" reRender="one"/>
    </apex:pageBlockButtons>
    <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>
    <apex:column value="{!a.name}"/>
    </apex:pageBlockTable>
    </apex:pageBlockSection>
    <apex:commandButton value="Click" action="{!main}" reRender="one"/>
    </apex:pageBlock>

     

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos