You need to sign in to do that
Don't have an account?
Saroja Murugan
Visual force page error
Hi All,
When im tryin to run my visual force code its shows the below error.
Can anyone guide how to solve this problem?
Thanks,
Saroja
Sweet Potato Tec
When im tryin to run my visual force code its shows the below error.
Can anyone guide how to solve this problem?
Thanks,
Saroja
Sweet Potato Tec
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:
Thank for the replay.
Already the vf page add to the user profile and the user profile is System Administrator.
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.
And im expecting output like below
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
https://test.salesforce.com/apex/YOURPAGENAME?id=CONTACTID
Replace "YOURPAGENAME" with your actual VF Page name
Replace "CONTACTID" with an actual Contact record ID.