+ Start a Discussion

nested map how to use

public Map<String, Integer> getqueuesMap(){

Map<String, Integer> qMap = new Map<String, Integer>();
queuesMap = new Map<String, Id>();
//list<aggregateResult> res=[select group.name,count(ID) from GroupMember group by group.name];
List<Group> roleGrps = [Select Id from Group where Type='Role' AND RelatedId= : UserInfo.getUserRoleId()];
Set<Id> gIds = new Set<Id>();
for(GroupMember grpM : [Select Group.Id, Group.Name from GroupMember where UserOrGroupId IN: roleGrps OR UserOrGroupId =: UserInfo.getUserId()])
queuesMap.put(grpM.Group.Name, grpM.Group.id);

list<aggregateResult> results = [SELECT Owner.Name,Count(Id) FROM Case where OwnerId in :gIds group by Owner.Name];

//system.debug('agregateResults' +results);
for (AggregateResult ar : results){
qMap.put(String.valueOf(ar.get('Name')), (Integer) ar.get('expr0'));
/* if(qMap.size() != queuesMap.size()){
for(string names : queuesMap.keySet()){
if(String.isNotBlank(names) && !qMap.containsKey(names)){

return qMap;

public void setqueuesmap(Map<String,Id> qmap){








I am using this code for getting queuenames and count of queuenames, but i want queueids ,is it possible by nestedmaps if can ,how to change this code?

how to done can anybody help me?