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
Andrew ShakalovAndrew Shakalov 

Unknown property in vf page.

I have a problem: Unknown Property  'PencilsNBoxesController.Pensil_box__c'

Here is a code.

<apex:page controller="PencilsNBoxesController">
  <apex:form> 
    <apex:pageBlock title="Pencil List" id="Pencil_Box_list"> 

    <apex:pageBlockTable value="{!Pencil_Box__c}" var="pb"> 
      <apex:column value="{!pb.Name}"/> 
      <apex:column value="{!pb.CreatedBy}"/> 

    </apex:pageBlockTable> 
    </apex:pageBlock> 
  </apex:form> 
</apex:page>

Controller 

public class PencilsNBoxesController {
public class PencilBoxListController {
private String sortOrder = 'CreatedBy'; 
public List<Pencil_Box__c> getPencil() { 
List<Pencil_Box__c> results = Database.query( 
 'SELECT Id, Name, CreatedBy FROM Pencil_Box__c'); 
return results; 

}
}
Nishant Prajapati 10Nishant Prajapati 10
Hi Andrew 
<apex:pageBlockTable value="{!pencil}" var="pb"> 
      <apex:column value="{!pb.Name}"/> 
      <apex:column value="{!pb.CreatedBy}"/>
</apex:pageBlockTable>

Please change the value attribute of pageBolockTabel from Pencil_Box__c to pencil, as shown above.
Andrew ShakalovAndrew Shakalov
Thank you for answer but then I have this: Unknown Property  'PencilsNBoxesController.Pensil' 
Nishant Prajapati 10Nishant Prajapati 10
public class PencilsNBoxesController {

    public List<Pencil_Box__c> getPencil() { 
        List<Pencil_Box__c> results = Database.query( 
         'SELECT Id, Name, CreatedBy FROM Pencil_Box__c'); 
        return results; 
    }
    
    public class PencilBoxListController {
        private String sortOrder = 'CreatedBy'; 
         
    }
}

Change your controller class as above.
Andrew ShakalovAndrew Shakalov
Great thanks! It works but I have new problem on my tab: No such column 'CreatedBy' on entity 'Pencil_Box__c'.  If you are attempting to use a custom field, be sure to append the '__c' after the custom field name.
     But CreatedBy is exist as Field Name on Pencil Box Object and have not the '__c'. 
Nishant Prajapati 10Nishant Prajapati 10
change your soql query to
SELECT Id, Name, CreatedById FROM Pencil_Box__c
Andrew ShakalovAndrew Shakalov
Then I have: SObject row was retrieved via SOQL without querying the requested field: Pencil_Box__c.CreatedBy 
Nishant Prajapati 10Nishant Prajapati 10
you also need to change reference on vf Page also,
<apex:pageBlockTable value="{!pencil}" var="pb"> 
      <apex:column value="{!pb.Name}"/> 
      <apex:column value="{!pb.CreatedById}"/>
</apex:pageBlockTable>

 
Andrew ShakalovAndrew Shakalov
Great thanks man! It works! But when I write input fields, my app breaks. May be you know how to upgrade my code to this app: User-added image
Nishant Prajapati 10Nishant Prajapati 10
What's the error you're getting now? 
Andrew ShakalovAndrew Shakalov
When I add <apex:inputText value="{!inputValue}" id="theTextInput"/>
Unknown Property  'PencilsNBoxesController.Pensil.inputValue
Nishant Prajapati 10Nishant Prajapati 10
public class PencilsNBoxesController {
    public string inputValue {get;set;}

    public List<Pencil_Box__c> getPencil() { 
        List<Pencil_Box__c> results = Database.query( 
         'SELECT Id, Name, CreatedBy FROM Pencil_Box__c'); 
        return results; 
    }
    
    
}

try above code