This issue is tormenting me for several hours . I am trying to populate an AggregateResult list with the results of a query, but the query returns only nulls. The SAME CODE, run in Execute Anonymous, executes correctly and returns what is needed. Any ideas?
List<GroupMember> users = new List<GroupMember>( [ Select UserOrGroupId From GroupMember Where GroupId IN ( Select ID from Group Where Name = 'IT Department' ) ]); List<ID> ids = new List<ID>(); for(Integer i=0;i < users.size() ; i++) ids.add(users[i].UserOrGroupId); AggregateResult owners = [Select OwnerID,COUNT(Name)NumberOfAssignees From Employee__c WHERE OwnerID IN :ids GROUP BY OwnerID]; System.debug(owners);