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
Raj R.Raj R. 

How to display Account and Opportunities fields as read only on VisualForce Page?

Hi,
A profile was created that was designed to provide read only access to Accounts and Opportunities.

I wanted to make a custom VisualForce (VF) page that displays Account and Opportunity fields that are references in ready only. How can I do this with a VF page?

For example,

I wanted to display the following:

Account 
  • Account Owner (lookup/reference field) as read only so it is not a clickable link
Opportunity
  • Opportunity Owner (lookup/reference field) as read only so it is not a clickable link

Best Answer chosen by Raj R.
Denis VakulishinDenis Vakulishin
Just rewrite like this 

Select Id, Name, OwnerId, Owner.Name From Account

 

All Answers

Denis VakulishinDenis Vakulishin
Hi,
You can just put Owner.Name as text in html. 
Raj R.Raj R.

Hi Denis,
How would the VF page code for that?

The following code below still displays the Owner as a clickable link.

<apex:outputText value="{!Account.Owner}"></apex:outputText>

Denis VakulishinDenis Vakulishin
<apex:outputText value="{!Account.Owner.Name}"></apex:outputText>
But you should request(select) Name field on Onwer
Raj R.Raj R.
Hi Denis,
Is this what you are referring to?

Select ac.Id, ac.Name, ac.OwnerId, (Select Id, Name From User Where Id=ac.OwnerId) From Account ac

Sorry, I am still new to SOQL. If not, how would I be able to query the name of the Account owner?
Denis VakulishinDenis Vakulishin
Just rewrite like this 

Select Id, Name, OwnerId, Owner.Name From Account

 

This was selected as the best answer
Raj R.Raj R.
That worked like a charm!

Thanks Denis!