function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gary Singh (BlackBeltHelp)Gary Singh (BlackBeltHelp) 

unable to fetch value from function

I am new to APEX and attempting to fetch value returned from a fuction of the same class, the sample below gives me NULL and no errors. 

Sounds silly, but I am unable to figure out I am doing wrong: 
public class ServiceCloudUtils {
    
    public static string getQueueId(string q){
        LIST<group> queueInfo = [SELECT Id from group WHERE name = :q and TYPE='queue'];
        Set<id> Idset = new Set<id>();
        string capturedId;
        for (group gvar: queueInfo){
         capturedId = gvar.id; 
        }
        system.debug('########### captured Queue Id : '+capturedId);
        return capturedId;        
    }
    
    public static list<GroupMember> getQueueMembers(string queueToFetch){
        list<string> queueMemberInfo = new list<string>();
        // call above function to fetch queueId
        string tempQId = getQueueId(queueToFetch);
        system.debug('##### id collected in tempQId : '+tempQId);
        // SOQL to fetch queue members
        list<GroupMember> gMembers = [Select UserOrGroupId From GroupMember where GroupId =:tempQId];
        system.debug('########### group Members for the Queue ID'+ tempQId +'are :'+ gMembers);
        return gMembers;
    }
   
}

 
AnkaiahAnkaiah (Salesforce Developers) 
Hi Gary,

Are you getting the values in all the debug statements?

Thanks!!
Gary Singh (BlackBeltHelp)Gary Singh (BlackBeltHelp)
Hi Ankaiah, 

None, I passing the following from anonymous window. 
 
Id TempId = ServiceCloudUtils.getQueueId('Helpdesk Tier 1 Group');
String temp = TempId;
ServiceCloudUtils.getQueueMembers(temp);

User-added image