3

I am new to Visualforce, and for the life of me I can't get a case standard list controller to show cases. It works for Accounts and Contacts, just not cases.

Here is the code:

<apex:page standardController="Case" recordSetVar="cases">
<apex:pageBlock title="Case List">

    <!-- Contacts List -->
    <apex:pageBlockTable value="{! cases }" var="cas">
        <apex:column value="{! cas.Id }"/>
        <apex:column value="{! cas.Status }"/>
    </apex:pageBlockTable>

</apex:pageBlock>
</apex:page>

Here is what it looks like: enter image description here

When I use this code:

    <!-- Contacts List -->
    <apex:pageBlockTable value="{! contacts }" var="ct">
        <apex:column value="{! ct.FirstName }"/>
        <apex:column value="{! ct.LastName }"/>
        <apex:column value="{! ct.Email }"/>
        <apex:column value="{! ct.Account.Name }"/>
    </apex:pageBlockTable>

</apex:pageBlock>

It works with contacts without a problem: enter image description here

Why does it work with Accounts and Contacts, but not Cases? Also why is the UI different for the contact list than the case list?

Edit: I should note that I do have 3 case records created so they should be showing up.

2
  • 1
    Copy-pasted your code, added closing </apex:page> and it works fine for me. Maybe the user viewing the page doesn't have appropriate FLS or sharing access to the records? Jul 24, 2019 at 20:01
  • @ThomasTaylor I forgot to paste it on the post but there is a </apex:page> closing tag on the visualforce page. This was done on a system administrator account in a sandbox with access to all the records and fields. I'm out of ideas why it would only not work for Cases.
    – EmptyStuff
    Jul 24, 2019 at 20:04

1 Answer 1

0

I know I'm a bit late on this but still, the reason reason you are not able to see the case records is because the page is displaying the cases based on the last filter you've used. To fix this, try accessing the Case tab and then click on All Cases in the View.

After that try refreshing your VF page. You should see all cases. The reason you were not able to see the records in the first place is because this page does not specify a filter in the request, so the page is displayed with the last used filter.

Hope this helps, Parikhit.

You must log in to answer this question.

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