You need to sign in to do that
Don't have an account?
SObject row was retrieved via SOQL without querying the requested field: Case.Account
I am trying to display the Account Name of the Case. I am running into this error message: "System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Case.Account." Any way to display the Account Name for the below code? I have checked the Schema in Eclipse on Case - AccountID and it shows c.Account.Name.
<apex:page standardController="Case" extensions="CaseListController" recordSetVar="cases" tabstyle="trouble_tickets__tab">
<apex:form id="theForm">
<apex:pageBlock title="Cases Home">
<b>You are viewing {!$User.FirstName} {!$User.LastName}'s Open and Closed Trouble Tickets</b>
</apex:pageBlock>
</apex:form>
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton action="/apex/CustomerPortalNewCase" value="Create New Case" id="newCaseButton"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!cases}" var="c" id="c_table">
<apex:column headervalue="Case Number">
<apex:outputLink value="/{!c.Id}" target="_self">{!c.casenumber}</apex:outputLink>
</apex:column>
<apex:column headervalue="Subject">
<apex:outputLink value="/{!c.Id}" target="_self">{!c.subject}</apex:outputLink>
</apex:column>
<apex:column headervalue="Priority">
<apex:outputField value="{!c.priority}"/>
</apex:column>
<apex:column Value="{!c.status}" style="{!IF(c.Status='New', 'color:brown;font-weight: bold',IF(c.Status='In Progress', 'color:green;font-weight: bold',IF(c.Status='Triaged', 'color:orange;font-weight: bold',IF(c.Status='On Hold','color:red;font-weight: bold',IF(c.Status='Resolution Provided','color:blue;font-weight: bold',IF(c.Status='Closed - Duplicate','color:black;font-weight: bold',IF(c.Status='Closed','color:black;font-weight: bold','color:grey')))))))}"/>
<apex:column headervalue="Created By">
<apex:outputField value="{!c.createdbyID}"/>
</apex:column>
<apex:column headervalue="Case Contact">
<apex:outputField value="{!c.contact.name}"/>
</apex:column>
<apex:column headervalue="Case Account">
<apex:outputField value="{!c.account.name}"/>
</apex:column>
<apex:column headervalue="Created Date">
<apex:outputField value="{!c.createddate}"/>
</apex:column>
</apex:pageBlockTable>
<apex:panelGrid columns="2" style="font-weight: bold;">
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}"><font color="blue">Previous</font></apex:commandLink>
<apex:commandLink action="{!next}" rendered="{!hasNext}"><font color="blue">Next</font></apex:commandLink>
</apex:panelGrid>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockSection >
<c:CaseQuickTipsGuideComponent />
<c:CaseAttachmentsInstructions />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Hi,
The mentioned error occurs, whenever you try to show fields, which have not been retrieved before by the corresponding Controller-Class (in your case it's called "CaseListController").
Check if he method called "getCases" (or any other method) in CaseListController retreives data with a SOQL query and extend the query with the required fields from Account (e.g. select id, Priority, Account.name from Case).
Regrads,
Sascha
All Answers
Hi,
The mentioned error occurs, whenever you try to show fields, which have not been retrieved before by the corresponding Controller-Class (in your case it's called "CaseListController").
Check if he method called "getCases" (or any other method) in CaseListController retreives data with a SOQL query and extend the query with the required fields from Account (e.g. select id, Priority, Account.name from Case).
Regrads,
Sascha
Solved my own Issue. I did not reference Account.Name in my extension.
Thanks for the above. I must have just noticed this while you submitted your reply.