You need to sign in to do that
Don't have an account?
Stephen E 4
List has more than 1 row for assignment to SObject... but we need to display more than one row.
I am trying to do a summary a a custom time object we have for Cases. I have embded the VFP on a cases page layout. When people enter time, it groups together the person entering the time, and the amount they have billed. But I keep getting the 'List has more than 1 row for assignment to SObject' error. I am not sure why, this query will 99% percent of the time have more than 1 record (or more than 1 person entering records) because of how our cases work. Why cant I display more than 1 record? Other Programs we have made will return multipe records and then we loop through them on the VFP to display. Not sure why there is a limit on this program though.
Code:
Code:
public class TimeSummaryController { public string caseid {get;set;} private final Case cc; public AggregateResult timeq {get;set;} public TimeSummaryController(ApexPages.StandardController stdController){ this.cc = (Case)stdController.getRecord(); } public AggregateResult getTimes(){ try { timeq = [SELECT Engineer_Name__r.Name enr,SUM(Total_Billed__c)total_billed FROM Time__c WHERE Case__c = :cc.Id GROUP BY Engineer_Name__r.Name ORDER BY SUM(Total_Billed__c) DESC]; }catch(Exception e){ System.debug(e); ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'No Time To Display')); return null; } return timeq; } }
<apex:page standardController="Case" extensions="TimeSummaryController" showHeader="false"> <apex:pageMessages ></apex:pageMessages> <apex:pageBlock> <apex:pageBlockTable value="{!Times}" var="tt" id="rr"> <apex:column value="{!tt['enr']}"/> <apex:column value="{!tt['total_billed']}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
Let us know if this will help you
All Answers
Let us know if this will help you