+ Start a Discussion
Saroja MuruganSaroja Murugan 

Visual force page error

Hi All,

When im tryin to run my visual force code its shows the below error.

User-added image
Can anyone guide how to solve this problem?

Thanks,
Saroja
Sweet Potato Tec
 
Gaurish Gopal GoelGaurish Gopal Goel
Hi Saroja,

Follow these steps:
1. Go to Setup
2. Quick find "Profiles"
3. Go to your user's profile
4. Add your Visualforce page in the related list "Enabled Visualforce Page Access" of that profile. See the screenshot for reference:

User-added image
Saroja MuruganSaroja Murugan
Hi Gaurish,

Thank for the replay.

Already the vf page add to the user profile and the user profile is System Administrator. 
Gaurish Gopal GoelGaurish Gopal Goel
Oh your ID parameter is wrong in the URL or somewhere in the controller. You need to put the correct ID.
Saroja MuruganSaroja Murugan
Here is my page and controllor.

Can you please tell me in which ID parameter is wrong?

Vf page

<apex:page standardController="Contact" extensions="RelatedController1">
<apex:form >
    <apex:pageBlock mode="Main detils">
        <apex:pageblockButtons >
            <apex:commandButton value="save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
         </apex:pageblockButtons>
        <apex:pageBlockSection title="Contact details">
            <apex:inputField value="{!contact.LastName}"/>
            <apex:inputField value="{!contact.FirstName}"/>
        </apex:pageBlockSection>
       <apex:pageblockSection title="Contact" id="scholid">
           <apex:inputField value="{!contact.School__r.Id}">
            <apex:actionSupport event="onchange" action="{!SchoolPopulated}" rerender="scholid, msgs" status="stat"/> 
          </apex:inputField>
          <apex:outputField value="{!contact.School__r.First_Name__c}"/>   
           <apex:outputField value="{!contact.School__r.Lastname__c}"/>   
           <apex:actionstatus startText="Getting Details" id="stat"></apex:actionstatus>
       </apex:pageblockSection>
                         
         
    </apex:pageBlock>
</apex:form>
</apex:page>

Controllor

public with sharing class RelatedController1
{
 private ApexPages.StandardController stdCtrl;
  
 public RelatedController1(ApexPages.StandardController std)
 {
  stdCtrl=std;
 }
  
 public void SchoolPopulated()
 {
  Contact cont=(Contact) stdCtrl.getRecord();
  if(!String.isBlank(cont.School__r.Id))
  {
      cont.School__r=[select First_Name__c,Lastname__c from School__c where id=:cont.School__r.Id];
  }
  else
   {
       cont.School__r=null;
   }   
 }
}

Here Contact is child and School__c is parent.
 
Gaurish Gopal GoelGaurish Gopal Goel
Please send me the URL you are using to view your VF page.
Saroja MuruganSaroja Murugan
When im click a preview button its show that error.

And im expecting output like below

User-added image

But its shows me like me the error.

And i refer the below link to achieve this.

http://bobbuzzard.blogspot.in/2011/11/retrieve-related-object-fields.html


 
Gaurish Gopal GoelGaurish Gopal Goel
so you need to pass a parameter in the URL like this:
https://test.salesforce.com/apex/YOURPAGENAME?id=CONTACTID

Replace "YOURPAGENAME" with your actual VF Page name
Replace "CONTACTID" with an actual Contact record ID.