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
PlarentPlarent 

Trouble with controller extension: Error: Unknown property 'ApexPages.StandardSetController.name'

Hi,  I have an object called Tasks__c and I am building an editable table for users to update the status of their tasks.  These are both my extension code and visualforce code.  I followed the guide to the word and cannot figure out why it is giving me an error:

 

<apex:page standardController="Tasks__c" recordSetVar="Tasks__c" extensions="TasksByUserID"
   tabstyle="My_Tasks__tab" sidebar="true">
   <apex:form > 
   <apex:pageBlock title="Hello {!$User.FirstName}!  Here are your tasks">
   <apex:pageMessages />
   <apex:pageBlockButtons >
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlockButtons>

   <apex:pageBlockTable value="{!taskRecords}" var="tsk">
      <apex:column value="{!tsk.name}"/>
      <apex:column value="{!tsk.Action_to_Perform__c}"/>      
      <apex:column value="{!tsk.AGN_Employee_Change__c}"/>
      <apex:column value="{!tsk.Application__c}"/>
      <apex:column value="{!tsk.Date_Due__c}"/>
      
      <apex:column headerValue="Current Status">
         <apex:inputField value="{!tsk.Current_Status__c}"/>
      </apex:column>

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

 

public with sharing class TasksByUserID {

    private final Tasks__c userTasks; 
    
    public TasksByUserID(ApexPages.StandardSetController controller) {

        this.userTasks = (Tasks__c)controller.getRecord();

    }
      
        public ApexPages.StandardSetController taskRecords{
        get {
            if(taskRecords == null) {
                return new ApexPages.StandardSetController(
                         Database.getQueryLocator(
                [SELECT name, Action_to_Perform__c, AGN_Employee_Change__c, Application__c, Date_Due__c,
                Current_Status__c FROM Tasks__c where Assigned_To__c =:Userinfo.getUserId()]));
            }
            return taskRecords;
        }
        private set;
    }
    
    public PageReference save() {
        return null;
    }
    public List<Tasks__c> getTasks() {
         return (List<Tasks__c>) taskRecords.getRecords();
    }  
    
}

 

Best Answer chosen by Admin (Salesforce Developers) 
DaveHDaveH

Try changing the table value to tasks instead of userTasks

 

<apex:pageBlockTable value="{!tasks}" var="tsk">

All Answers

DaveHDaveH

StandardSetControllers are used to work on Lists, not a single instance of an object. Your userTasks member variable should be a list (List<Tasks__c>) and the in the contructor you should be using 

this.userTasks = (List<Tasks__c>)controller.getRecord();

PlarentPlarent

Hi DaveH,

 

Thanks for helping out.  This does not solve my problem.  I still get the same error message when I change the userTasks to be List<Tasks__c> and the constructor to be 

this.userTasks = (List<Tasks__c>)controller.getRecords();

 

Any other ideas?

 

Thanks,

 

Plarent

DaveHDaveH

Try changing the table value to tasks instead of userTasks

 

<apex:pageBlockTable value="{!tasks}" var="tsk">
This was selected as the best answer
PlarentPlarent

It worked.  Thanks!!!!!!