I'm using Salesforce Classic. I've created a custom object called Proposal. Users view/edit this object via a page layout. I've embedded a Visualforce page in the layout. However, the fields in the Visualforce page are editable when users are viewing the custom object. I'd like the Visualforce page to be in read only mode when users are not editing the custom object. Is this possible?
Best Answer
To display a page in read-only mode you can use page attribute as follows:
Secondly, change the
<apex:inputField>
to<apex:outputField>
Other advantage is query limit is getting increased from 50,000 rows to 1,000,000 rows.
Also, Visualforce controller methods with the
@ReadOnly
annotation automatically take advantage of read-only mode.For more information refer Setting Read-Only Mode for an Entire Page
and Setting Read-Only Mode for Controller Methods
Update
You can create a routing page, which will make the decision if editable or read-only page to be displayed.
Lets's say routing page is =
VFRouting.page
In this page onload, you can take the URL and decide if this is to be navigated to read-only page or editable page.
Create 2 visualforce pages one for
read-only
and other foreditable
And finally embed the
VFRouting.page
in page layout.