Activity › Forums › Salesforce® Discussions › How To add link on the Account Name for below given Scenario ?
Tagged: Account, Contact Record, Custom Link, Help & Training, Hyperlink, Salesforce Customization, URL Field
-
How To add link on the Account Name for below given Scenario ?
Posted by Aman on July 18, 2017 at 2:20 PMwhen we click on the link we get the description field and contact Associated with that account
shariq replied 8 years, 9 months ago 2 Members · 1 Reply -
1 Reply
-
Hi Aman,
You can try this:-
Apex Controller
public class AccountLink
{
public String linkId {get;set;}
public List<Contact> con{get;set;}
public String searchString{get;set;}
public List<Account> acct{get;set;}public void search1()
{acct= Database.query(‘Select Name, description From Account WHERE Name LIKE \’%’+searchString+’%\’ Limit 100′);
con = new List<contact>();
}public void link()
{con = [SELECT Id, Description, AccountId FROM Contact WHERE AccountId =:linkId LIMIT 100];
}
}Apex Page
<apex:page controller=”AccountLink” sidebar=”false” id=”page”>
<apex:form >
<apex:actionFunction action=”{!search1}” name=”callingApex” reRender=”idBlock1″/>
<apex:pageBlock Id=”idBlock”>
<apex:inputText value=”{!searchString}” onkeyup=”callApex()” />
<apex:pageBlockButtons >
<apex:commandButton value=”search” action=”{!search1}” rerender=”idBlock1″/>
</apex:pageBlockButtons><apex:pageBlockTable value=”{!acct}” var=”account” id=”idBlock1″>
<apex:column headerValue=”Account Name” >
<apex:commandLink value=”{!account.name}” action=”{!Link}” reRender=”idPage”>
<apex:param value=”{!account.Id}” name=”ContactsShow” assignTo=”{!linkId}” />
</apex:commandLink>
</apex:column>
<apex:column ><apex:pageBlockTable value=”{!con}” var=”contact” id=”idPage”>
<apex:column value=”{!contact.Description}”/>
<apex:column value=”{!contact.Id}”/>
</apex:pageBlockTable></apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<script>
function callApex()
{
callingApex();
}
</script>
</apex:page>Hope this helps.
Log In to reply.