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
Jina ChetiaJina Chetia 

How can I have readonly fields in VisualForce Page?

Hi,

I have a requirement to create a summary page which contains all the data related to a custom object or rather all the fields in that object but those values should appear as read-only. There will be a 'Edit' button on the page and on click of it all the fields should become editable.

How do I go about achieving this?

Regards,
Jina
Best Answer chosen by Admin (Salesforce Developers) 
Ralph CallawayRalph Callaway
Hi Jina,

If you're just looking to create a standard summary page the following code should help you out.

Code:
<apex:page>
<apex:detail/>
</apex:page>

 
If it looks simple, well it is.  To test it you'll need the ID of one of your custom objects.  If you open one the url will look something like this:

https://na3.salesforce.com/a0350000006VljmAAC

copy the 18 character id and append it to the url for your apex page, for example:

https://na3.salesforce.com/apex/pos?id=a0350000006VljmAAC

Is this what you were looking to accomplish Jina?

- Ralph