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
khushbu dubeykhushbu dubey 

i have written code for standard controller ..is it correct??

<apex:page standardController="Account">
<apex:pageBlock >
<apex:pageBlockSection title="Account information">
<apex:outputField value="{!Account.Name}"/>
<apex:outputField value="{!Account.Type}"/>
<apex:outputField value="{!Account.Industry}"/>
<apex:outputField value="{!Account.Phone}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

 
Best Answer chosen by khushbu dubey
Amit Chaudhary 8Amit Chaudhary 8
Yes your code is look good to me to display the record.

Remember, for this page to display account data, the ID of a valid account record must be specified as a query parameter in the URL for the page. For example:
https://Salesforce_instance/apex/myPage?id=001x000xxx3Jsxb

But if you want to get the value and save it then try below code
<apex:page standardController="Account">
  <apex:form>
    <apex:pageBlock title="My Content" mode="edit">
      <apex:pageBlockButtons>
        <apex:commandButton action="{!save}" value="Save"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection title="My Content Section" columns="2">
        <apex:inputField value="{!account.name}"/>
        <apex:inputField value="{!account.site}"/>
        <apex:inputField value="{!account.type}"/>
        <apex:inputField value="{!account.accountNumber}"/>
      </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>
PLease check below post for more information
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_std_actions.htm
https://developer.salesforce.com/page/Building_Visualforce_Pages_Using_the_Standard_Controller

Let us know if this will help you

All Answers

Mahesh DMahesh D
Hi Khushbu,

The above code is correct and when you are executing it, use the below URL

https://c.na2.visual.force.com/apex/AccStdController?Id=0014000000HJXxF

Here you have to change your Server name and take any account id from your environment.

Please do let me know if it helps you.

Regards,
Mahesh
Amit Chaudhary 8Amit Chaudhary 8
Yes your code is look good to me to display the record.

Remember, for this page to display account data, the ID of a valid account record must be specified as a query parameter in the URL for the page. For example:
https://Salesforce_instance/apex/myPage?id=001x000xxx3Jsxb

But if you want to get the value and save it then try below code
<apex:page standardController="Account">
  <apex:form>
    <apex:pageBlock title="My Content" mode="edit">
      <apex:pageBlockButtons>
        <apex:commandButton action="{!save}" value="Save"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection title="My Content Section" columns="2">
        <apex:inputField value="{!account.name}"/>
        <apex:inputField value="{!account.site}"/>
        <apex:inputField value="{!account.type}"/>
        <apex:inputField value="{!account.accountNumber}"/>
      </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>
PLease check below post for more information
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_std_actions.htm
https://developer.salesforce.com/page/Building_Visualforce_Pages_Using_the_Standard_Controller

Let us know if this will help you
This was selected as the best answer