You need to sign in to do that
Don't have an account?
Jeffrey Zhang
getting System.ListException: Row with null Id at index 0 error with my Map AggregateResult
Not too familiar with maps and aggregateResult in SF, so I'm not sure if this is a formatting issue or something else, but I keep getting that error in my trigger when this is called.
Is it a formatting issue, or something else?
Thanks.
Map<Id,aggregateResult> maxDates = new Map<id,AggregateResult>([Select whoid id, Max(Sales_Activity_Date__c) myMax, Min(Sales_Activity_Date__c) myMin from Task where whoid = :who and status = 'Completed' and whoid!=NULL GROUP BY whoid]);
Is it a formatting issue, or something else?
Thanks.
... Error. Caramba!
and now try this:
... it works fine!!
Bizarre but Jeffrey was right excepted for the "id".
Alain
All Answers
Try replacing; Select whoid id, by Select whoid Id,
(uppercase for the "I")
Regards
Alain
Why cant we use the List Agregate result and iterate over it to get the desired results?
something like this should work
<pre>
for(AggregateResult maxDatesAggregateResult:[Select whoid id, Max(Sales_Activity_Date__c) myMax, Min(Sales_Activity_Date__c) myMin
from Task
where whoid = :who
and status = 'Completed' and whoid!=NULL
GROUP BY whoid]){
String id = String.valuesOf(maxDatesAggregateResult.get('id'));
Double myMax = Double.valuesOf(maxDatesAggregateResult.get('myMax'));
Double myMin = Double.valuesOf(maxDatesAggregateResult.get('myMin'));
//do you logic here
}
</pre>
also the code is being used in Trigger, so you should use the trigger ID that is in context. In this case i am assuming :who is list of Ids that are created from trigger that is in context
... works perfectly !! Just change "id" with "Id".
Alain
... Error. Caramba!
and now try this:
... it works fine!!
Bizarre but Jeffrey was right excepted for the "id".
Alain
cheers!
It's always the littlest of things that causes the biggest headaches.
I have:
Map<Id, AggregateResult> lastY = new Map<Id, AggregateResult>([select Line__c, sum(number_of_calls__c) totalcalls from detailed_call_data__c where (date__c >= :dateStart.addYears(-1)) and (date__c <= :dateEnd.addYears(-1)) and Line__c != '' group by Line__c]);
and getting the same error. Any ideas anyone?
Map<Id, AggregateResult> m = new Map<Id, AggregateResult>([Select AccountId, Count(Name) from Contact GROUP BY AccountId]);