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?
To display a page in read-only mode you can use page attribute as follows:
<apex:page controller="myController" readOnly="true">
<apex:page>
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.
While Visualforce pages that use read-only mode for the entire page can’t use data manipulation language (DML) operations, they can call getter, setter, and action methods which affect form and other user interface elements on the page, make additional read-only queries, and so on
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 for editable
And finally embed the VFRouting.page
in page layout.
-
Thanks for your answer, but it doesn't address the problem I have. – Michael Sobczak Nov 17 '16 at 23:44
-
-
Thanks for the update, but your answer still doesn't address the issue I have. The Visualforce page is being displayed within a Custom Object page layout. I don't have control over the links the user uses to open the Standard Object. – Michael Sobczak Nov 18 '16 at 0:03
-
-
urls are different in view mode and edit mode, edit mode will have '/e' appended after recordId – Santanu Boral Nov 18 '16 at 0:08
<apex:outputField>
instead of<apex:inputField>
. I don't quite follow when you would want these fields to be editable in your custom page. – Adrian Larson♦ Nov 17 '16 at 17:49Visualorce Page
is not displayed in edit mode, no? – Adrian Larson♦ Nov 17 '16 at 20:12