0

Please help - I want to count the list size so I will only render it in Visualforce page if > 0. My error is:Variable does not exist: getCasesInApproval at line 15 column 18
Vairable does not exist? I don't get - I just made a list. My Code:

public class MyConnectivityCasesSales {


    public MyConnectivityCasesSales(ApexPages.StandardController controller) {

    }




   public List <Case> getCasesInApproval (){ 
       return [select subject, CaseNumber, Contact.name, owner.name, Reason, Account.name, Status, Approval_Status__c, LastModifiedDate   from Case where Salesperson__c =:userinfo.getuserId() and isClosed !=TRUE ];
    }

  Integer size = getCasesInApproval.size();



}
  • getCasesInApproval isn't a List in scope, it's the name of a method... – Brian Mansfield Nov 19 '15 at 19:00
2

You can directly check the size in your visualforce page as follows

<apex:page controller="MyConnectivityCasesSales">
<apex:form>
<apex:outputpanel rendered="{!CasesInApproval.size!=0}">
<!-- Show only if size is greater than 0 -->
</apex:outputpanel>

</apex:form

</apex:page>
| improve this answer | |
2

When referencing a list in visualforce you can directly access the size using the syntax: {!myList.size} You could then create a boolean statement in Visualforce with rendered="{!myList.size > 0}". Note that size is a property and not a function in Visualforce.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.