function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lovetolearnlovetolearn 

Creating links

If I created a datatable that displays all my contacts, how would I be able to create a link for my users so that when the contact name is clicked their account information is displayed? 

 

Please help. Thank you. 

Best Answer chosen by Admin (Salesforce Developers) 
lovetolearnlovetolearn

 

<apex:dataTable value="{!myMember}" var="aMember" width="250%" cellpadding="3" border="2">
                    <apex:column >
                        <apex:facet name="header">ID Number</apex:facet>
                            {!aMember.Name}
                    </apex:column>
                    
                     <apex:column >
                        <apex:facet name="header">Name</apex:facet>
                            <apex:commandLink value="{!aMember.First_Name__c & ' ' & aMember.Last_Name__c}"/>
                    </apex:column>

</apex:datatable> 

 

Thank you!

All Answers

Alex_ConfigeroAlex_Configero

 

<apex:datatable value="{!contacts}" var="c">
<apex:column>
<apex:outputLink value="/{!c.AccountId}">
 {!c.Name}
</apex:outputLink>
</apex:column>
</apex:datatable>

 

Something like the above should do it, or paste here what you have so far and we can edit your code.

 

lovetolearnlovetolearn

 

<apex:dataTable value="{!myMember}" var="aMember" width="250%" cellpadding="3" border="2">
                    <apex:column >
                        <apex:facet name="header">ID Number</apex:facet>
                            {!aMember.Name}
                    </apex:column>
                    
                     <apex:column >
                        <apex:facet name="header">Name</apex:facet>
                            <apex:commandLink value="{!aMember.First_Name__c & ' ' & aMember.Last_Name__c}"/>
                    </apex:column>

</apex:datatable> 

 

Thank you!

This was selected as the best answer
Alex_ConfigeroAlex_Configero

 

<apex:dataTable value="{!myMember}" var="aMember" width="250%" cellpadding="3" border="2">
                    <apex:column >
                        <apex:facet name="header">ID Number</apex:facet>
                            {!aMember.Name}
                    </apex:column>
                    
                     <apex:column >
                        <apex:facet name="header">Name</apex:facet>
                         <apex:outputLink value="/{!aMember.Account__c}">
                        {!aMember.First_Name__c}  {!aMember.Last_Name__c}
                         </apex:outputLink>
                    </apex:column>

</apex:datatable> 

 Something like this should do it (not sure what the Account relationship is called in your custom object, I assumed Account__c)

 

lovetolearnlovetolearn

how do i call upon the record ID of the record? Not the one generated by my salesforce page, but the record id in the url. 

Alex_ConfigeroAlex_Configero

 

Not sure what you mean bu "call upon." What are you trying to accomplish?

lovetolearnlovetolearn

the apex code works perfectly. What should i replace Account__c with though so it will pass the Record ID through?

 

                        <apex:outputLink value="/{!aMember.Account__c}">
  
Alex_ConfigeroAlex_Configero

 

What si the name of the field that links aMember to the account? That is what you should be using.

lovetolearnlovetolearn

I am not sure that i understand. "aMember" is the variable that i created to pass through the datatable. 

lovetolearnlovetolearn

Never mind I got it. Thank you so much.