You need to sign in to do that
Don't have an account?
Pull Fields from Extension
Hello,
This is probably a simple answer, but I am getting an error when I try to create a VF page using pageBlockSections. My page has the Account as the standard controller and a custom controller to pull through the Account Name to the data I am entering for my custom object (Client Status__c). When I try to save, i get the error: Error: Unknown property 'AccountStandardController.Client_Status__c'. Can anyone help? My code is below:
<apex:page standardController="Account" tabStyle="Account" extensions="StatusController">
<apex:form >
<apex:pageBlock title="Client Status">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" rerender="detail" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="GENERAL INFORMATION" columns="2">
Client Name:
<apex:outputField value="{!score.Client_Name__c}" />
The Client is a(n):
<apex:inputField value="{!score.Type_of_Client__c}"/>
The Client Licenses:
<apex:inputField value="{!score.Client_Licenses__c}"/>
</apex:pageBlockSection>
</pageBlock>
</Form>
</Page>
So in this controller, score is a list of Client_Status__c records, but in your page you are attempting to use it as an instance:
The error message is a bit weird, but essentially the problem is that a list doesn't have a property named Client_Name__c. I would say you should either be iterating the list:
or change the controller so that score is a single instance of a Client_Status__c record.
All Answers
Can you post the controller code? This usually means that the field/property you are trying to access isn't exposed properly from the extension controller. The error message is a bit confusing as the platform always assumes the field/property should be coming from the standard controller.
Hi Bob,
My controller is below:
public class ScorecardController{
public List<Client_Status__c> score {get; set;}
private final Account acct;
public ScorecardController(ApexPages.StandardController myController) {
acct=(Account)myController.getrecord();
score = new List<Client_Status__c>();
Client_Status__c score2 = new Client_Status__c();
score2.Client_Name__c = acct.id;
score.add(score2);}
public PageReference save() {
insert score;
PageReference RetPage = new PageReference('/' + score[0].id);
RetPage.setRedirect(true);
return RetPage; }
}
So in this controller, score is a list of Client_Status__c records, but in your page you are attempting to use it as an instance:
The error message is a bit weird, but essentially the problem is that a list doesn't have a property named Client_Name__c. I would say you should either be iterating the list:
or change the controller so that score is a single instance of a Client_Status__c record.
Thanks Bob, that did the trick!!
Hi Bob,
Sorry, 1 other question. If I wanted to put an IF condition on a pageSectionItem in this page, how would I need to call the variable? Below is the line I am trying to code but it won't recognize the variable:
<apex:pageBlockSectionItem rendered="{!IF(stat.Type_of_Client__c <> 'Health','true','false')}">
I have a question as well. In the original post the first line is:
<apex:page standardController="Account" tabStyle="Account" extensions="StatusController">
which says the name of the controller ext is "StatusController"
But the first line of the posted Controller is:
public class ScorecardController{
...a different name.
What am I missing?
tia... Bob
That looks about right for conditionall rendering the section. What error do you get?
Hi Bob,
It seems to be working now. I must have had some bad code somewhere. Thanks for your help!!