My code is in visualforce page :- Something {!r.plancount} {!rep.name} for something

Getting error :-

Error: Unknown property 'String.plancount'  

for !rep.name I ma not getting any error.. I am using class myclassname ...

public without sharing class myclassname {

public integer plancount {get;set;}
public integer savedplancount;

public rep_profile__c therep{get;set;}
public list<websiteUtilities.ratingwrapper> thelist{get;set;}

public list<websiteUtilities.ratingwrapper> getratings(){        
    if (ApexPages.currentPage().getParameters().get('Id')==null) thelist=websiteUtilities.getRatingWrapperForREP();
    return thelist;

public rep_profile__c getrep(){
    therep=[select id, createdby.firstname, name, about_us__c, star_rating_avg__c, total_reviews__c, logo_url__c, snapshot_id__c 
            from rep_profile__c where id =: ApexPages.currentPage().getParameters().get('Id') limit 1];
    return therep;

public list<rate__c> getRates(){
    list<rate__C> theRates = [select id, plan__r.name from rate__c 
                              where plan__r.rep_profile__r.id =: ApexPages.currentPage().getParameters().get('Id') 
                              and active__c = true AND plan__r.active__c = true AND suspended__c = false 
                              AND plan__r.suspended__c = false AND plan__r.plan_start_date__c <= today AND plan__r.plan_end_date__c >today ];
    return theRates;

   public void getactivePlans(){//generates the plan list (really a list of rates)
        /*old version for single tdsp.  
        planlist=websiteCalc.getactivePlans();  */

       //new version that considers usage, premise type, and TDSP
       planlist = websiteCalc.getACtivePlans(premise, theAPA, tdspid);
        for (rate__c item:planlist){
            for(REP r:GetCompanyPicklist() ){  //gets the REP ids for the left-side picklist
                if (r.company.id == item.plan__r.REP_Profile__r.id){ r.plancount++ ;}
            if (item.plan__r.contract_length__c>12) {moreThan12Count ++;}  //populate the contract lenght plan count numbers
            else if (item.plan__r.contract_length__c==12){exactly12count ++;}
                 else if ((item.plan__r.contract_length__c>5)&&(item.plan__r.contract_length__c<11)){from6to11Count ++;}
                     else if (item.plan__r.contract_length__c<6){lessThan6Count ++;} 



    public integer GetSavedPlanCount(){
        if (theAPA!=null){
            return websiteUtilities.fetchSavedPlans(theAPA).size();
        } else return 0;

        public class REP{
            public REP_Profile__c company {get;set;}
            public boolean OK {get;set;}
            public integer plancount {get;set;}

            public REP(){


My visualforce page :-

<apex:page sidebar="false" controller="myclass" showHeader="false">
<apex:outputpanel styleClass="sub-title" layout="block">
        <div id="logo-wrap"> 
             <div class="logo-bg">
               <div align="center" style="width:77px; margin:0 auto;">
  <h2>Compare {!r.plancount} {!rep.name}  <br/>
                <span>To discover you</span></h2>   
                <a href="#" class="compare">Compare {!rep.name} now</a> 
                <a href="#" class="register">Now</a> 


I have checked in google for this apex error but not able to find it..

Help me !!

  • please share your controller class also.
    – doga
    Feb 11, 2013 at 10:15
  • @doga I have added a code related to class Feb 11, 2013 at 10:28
  • you can simply use {!plancount}. no need to use "r"
    – doga
    Feb 12, 2013 at 3:26

2 Answers 2


Check the r.plancount in your controller

  1. If it's a property - does it have a public getter (for example public String plancount {get; private set;}
  2. If it's a method - is it a public getter (public String getPlancount())
  3. If it's coming from an sObject - it probably should be plancount__c?
  4. If all above looks ok and you're out of ideas - maybe the field visibility? Is the field marked as visible for your Profile?
  5. r or rep? They're 2 different variables or did you forget to copy-paste-search-replace something?

The error message is looking weird too, it's as if r would be already a string. Do you use <apex:repeat>, <apex:variable> or something similar around the line you've posted?


r is not visible to visualforce. That's because (as far as I can see) you have only 1 loop where you do something related to it.

for(REP r:GetCompanyPicklist() ){
    if (r.company.id == item.plan__r.REP_Profile__r.id){ r.plancount++ ;}

Look at it closer. You get some values, you loop through them, modify them a bit and then you discard them because loop is finished. It's useless. But it's also useless because even if you'd save them to a helper list variable - you increment a counter on each record separately (each will increment from 0 to 1 and that's it) while I think you're after getting a total count of ones that match criteria.

Something like this MIGHT be better (your code is hard to understand, don't know what you're really after).

plancount = 0; // that's the "public integer plancount {get;set;}", not the one from REP class
for(rate__c item:planlist){
    for(REP r:GetCompanyPicklist() ){  //gets the REP ids for the left-side picklist
        if (r.company.id == item.plan__r.REP_Profile__r.id){ plancount++ ;} // notice no "r.plancount"
  • How to check for sObject in salesforce... Its create/object... r and rep are two different variables... for plancount we have written some class code... I checked plancount property is public... and method are also public... do you have any other idea ?? Feb 11, 2013 at 10:20
  • Just post a bit more of both Visualforce and the controller (the part that defines and later uses this plancount). Main question: is it a field on sObject or a variable that exists only in controller. If it's a field - setup -> create -> objects -> find the object -> find the field -> "set field level security" and is it at least visible for your profile.
    – eyescream
    Feb 11, 2013 at 10:27
  • Updated my code !! Feb 11, 2013 at 10:28
  • Don't see anything weird in the controller. Can you post visualforce too? You can't expect any help if you add incomplete sources (for example looking at it I'd say there's no way rep.name should work because it's not a variable and also doesn't look like any of queries shown is using Name field)...
    – eyescream
    Feb 11, 2013 at 10:44
  • Update my code for page and show the code related to rep.. Feb 11, 2013 at 11:03

The issue is that you don't have variable named r at all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .