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
BDArnzBDArnz 

Unknown Property Error

I don't understand why I'm getting the error :
 
ErrorError: Unknown property 'MyOpenActivities.MyCasesToDo'
 
Here's the page code:
 
Code:
<apex:page controller="MyOpenActivities">
    <apex:form >
    <apex:pageblock Title="Hello {!$User.FirstName} {!$User.LastName}" id="TitleBlock">
        <h1> Version 1.0 </h1><br />
        Here are the lists for open Technical Support Activities that require your attention.<br />
        Open Cases, Service Activity and Demos.<br />
    </apex:pageblock>
    </apex:form>
    
    <apex:form >
    <apex:pageblock title="My Open Cases">
    
       <apex:pageBlockTable value="{!MyCasesToDo}" var="c">
        
        </apex:pageblocktable>
    </apex:pageblock>
    </apex:form>
</apex:page>

 
Here's the controller:
 
Code:
public class MyOpenActivities {

Public String CurrentUserId {get; set;}
Public List<Case> MyCasesToDo;

Public MyOpenActivities(){
 this.CurrentUserId=UserInfo.getUserId();
}

public List<Case> getMyCasesToDo(string CurrentUserId){
 List<Case> MyCasesToDo = new Case[]{};
 MyCasesToDo = [Select OwnerId, Subject, Status, Service__c, Priority, Origin, Id, Description, ContactId, Account.Name, AccountId From Case Where OwnerId = :CurrentUserId];
 return MyCasesToDo; 
}
 
Static testMethod void testThisController() {
 MyOpenActivities testController = new MyOpenActivities();
 string CurrentUserId=UserInfo.getUserId();
 testController.getMyCasesToDo(CurrentUserId);
 
}

}

 
I've done this exactly the same way on quite a number of other page/controllers.  Any idea why it's happening now?
 
Best Answer chosen by Admin (Salesforce Developers) 
Sam.arjSam.arj
Your property can not have a parameter.

Do it this way:

Code:
private String CurrentUserId;

Public MyOpenActivities(){
 this.CurrentUserId=UserInfo.getUserId();
}

public List<Case> getMyCasesToDo(){
 List<Case> MyCasesToDo = new Case[]{};
 MyCasesToDo = [Select OwnerId, Subject, Status, Service__c, Priority, Origin, Id, Description, ContactId, Account.Name, AccountId From Case Where OwnerId = :CurrentUserId];
 return MyCasesToDo; 
}

 






All Answers

Sam.arjSam.arj
Your property can not have a parameter.

Do it this way:

Code:
private String CurrentUserId;

Public MyOpenActivities(){
 this.CurrentUserId=UserInfo.getUserId();
}

public List<Case> getMyCasesToDo(){
 List<Case> MyCasesToDo = new Case[]{};
 MyCasesToDo = [Select OwnerId, Subject, Status, Service__c, Priority, Origin, Id, Description, ContactId, Account.Name, AccountId From Case Where OwnerId = :CurrentUserId];
 return MyCasesToDo; 
}

 






This was selected as the best answer
BDArnzBDArnz
Thank you Sam.arj for your quick reply.  That took care of it!  (I had forgotten that in my other situations I wasn't passing a parameter).
Sam.arjSam.arj

 Your welcome and thank you for your support of the community.

  http://salesforcesource.blogspot.com