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
SakthidasanSakthidasan 

how to display record from vf page

I'm learning vf page.I am struggling display a record from vg page.I copy the id of the contact record and past in url like same(https://***Salesforce_instance***/apex/HelloWorld2?id=001D000000IRt53) but I'm not see the record in vf page.my code here:

<apex:page standardController="Contact">
<apex:form >
<apex:pageBlock title="Quick Edit: {!Contact.Name}">
<apex:pageBlockSection title="Contact Details" columns="1">
<apex:inputField value="{!Contact.Phone}"/>
<apex:outputField value="{!Contact.MobilePhone}"
label="Mobile #"/>
<apex:inputText value="{!Contact.Email}"
label="{!Contact.FirstName + '’s Email'}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Best Answer chosen by Sakthidasan
Mahesh DMahesh D
Hi Sakthidasan,

Please save the VF Page by going to Setup --> Build --> Develop --> Visualforce Page

Because some times it will not take the Query string parameters when you use the editor from Developer Mode.

Regards,
Mahesh

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Can you please post the screen shot of your VF page with URL. your code is good you just need to pass id in URL

https://na1.salesforce.com/apex/HelloWorld2?id=001D000000IRt53

Look like ID you are passing for account(001D000000IRt53) contact id always start with 003.
Mahesh DMahesh D
Hi Sakthidasan,

Please find the below code:
<apex:page standardController="Contact">
    <apex:form >
        <apex:pageBlock title="Quick Edit: {!Contact.Name}">
            <apex:pageBlockSection title="Contact Details" columns="1">
                <apex:inputField value="{!Contact.Phone}"/>
                <apex:outputField value="{!Contact.MobilePhone}"
                label="Mobile #"/>
                <apex:inputText value="{!Contact.Email}"
                label="{!Contact.FirstName + '’s Email'}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

I also tested the above code in my DE environment.

User-added image

Go through the Trailhead module:

https://developer.salesforce.com/trailhead/en/visualforce_fundamentals/visualforce_output_components

Also go through the below links:

https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_visualforce_3.htm

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_display_field_values.htm

http://salesforce.stackexchange.com/questions/22947/visual-force-page-for-records-retrieval



Please do let me know if it helps you.

Regards,
Mahesh
SakthidasanSakthidasan
I've attced file please check ,what is the problem in the vf page I can't get the data in vf pageUser-added image
Mahesh DMahesh D
Hi Sakthidasan,

Please save the VF Page by going to Setup --> Build --> Develop --> Visualforce Page

Because some times it will not take the Query string parameters when you use the editor from Developer Mode.

Regards,
Mahesh
This was selected as the best answer
SakthidasanSakthidasan
Thanks Mahesh,
                 after I save the page (Setup --> Build --> Develop --> Visualforce Page) I get the record from vf page