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
justynjustyn 

Make a link not a link!

I have a search page for my custom object and in the result display the Member field (linked to Contact) is automatically clickable. I don't want this to be the case. Can I disable this?

 

The code for the section is:

 

<apex:column >               

<apex:facet name="header">                   

<apex:commandLink value="Member" action="{!toggleSort}" rerender="results,debug">                       

<apex:param name="sortField" value="member" assignTo="{!sortField}"/>                   

</apex:commandLink>               

</apex:facet>               

<apex:outputField value="{!counselling_practice.Member__c}"/>           

</apex:column>

 

Thanks in advance

 

Justyn

Best Answer chosen by Admin (Salesforce Developers) 
hchhch

In your apex controller instead of retrieving Counselling_Practice__c.Member__c field retrieve "Counselling_Practice__c.Member__r .Name" in your SOQL

All Answers

ptepperptepper

Are you referring to this?

 

<apex:outputField value="{!counselling_practice.Member__c}"/>    

 

If so, have you trying apex:outputText?

justynjustyn

Hi

 

Thanks for the suggestion. If I use fieldText it does remove the link, but it just shows the contact ID rather than the Contact Name. Any thoughts?

 

Justyn

hchhch

Use <apex:outputText value="{!counselling_practice.Member__r.Name}"/> .

It will display only Name.

justynjustyn

Hi

 

That correction makes sense and the page accepts the changes. However I then get the following error message:

 

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Counselling_Practice__c.Member__r 

Visualforce Error

 

 

The Member fields is a Master-Detail relationship to Contacts. Name of course does existing in Contacts. Is it going to be something to do with my Apex Controller?

 

Regards

 

Justyn

hchhch

In your apex controller instead of retrieving Counselling_Practice__c.Member__c field retrieve "Counselling_Practice__c.Member__r .Name" in your SOQL

This was selected as the best answer
justynjustyn

Works a dream. Thanks