You need to sign in to do that
Don't have an account?

Getting QUEUEMEMBERS IN QUEUE........?
Hi friends,
Can u pls help me to get all queuemembers in Queue?
Is there any SOQL query to get this! pls Help me regarding this........
Thank U
Sfdcbluefish
Hi SfdcBlueFish,
Queue and queue members are managed using two tables in Salesforce, Group and GroupMember. Queues are stored as records in the table Group with 'Type' as "Queue".
The query [Select Id from Group where type='Queue' and Name='Queue Name'] will return the Id of the required queue in the system.
Use this Id of the queue in the query [Select UserOrGroupId From GroupMember where GroupId =:reqdGroupId] to fetch all the users or groups which are members of the required queue.
For more information, refer the documentation.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_group.htm
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_groupmember.htm
All Answers
Hi SfdcBlueFish,
Queue and queue members are managed using two tables in Salesforce, Group and GroupMember. Queues are stored as records in the table Group with 'Type' as "Queue".
The query [Select Id from Group where type='Queue' and Name='Queue Name'] will return the Id of the required queue in the system.
Use this Id of the queue in the query [Select UserOrGroupId From GroupMember where GroupId =:reqdGroupId] to fetch all the users or groups which are members of the required queue.
For more information, refer the documentation.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_group.htm
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_groupmember.htm
Thank u Oxene,
Thank u...............................very much
Hi,
If the UserOrGroupId in the GroupMember is assigned with public GroupId or Roles instead of the user then how to get the userId from the public group and roles?
how to identify the UserOrGroupId is not a userId?
Thanks
Saleem
1.Put UserOrGroupId in the list
2.Use the String.value function to get the subtring(0,3).
3. If first three letters are '005' then it is a user and if it is '00G' then it is a group.
Dnt have time to put the error-free code .If you need that i 'll also provide that today . but little Later
HI Everyone,
I have a similar requirement as in the post,could someone reply to me
I override my standard convert button with a VF page ,which will convert lead to account ,contact,opportunity through controller.i have three roles in my org which are 'salesrep','executive','manager'.I need it should execute (Lead conversion) only when
1) Sales Rep can convert their own leads, and Lead owned by a Queue they are a member of
2) If Sales Rep converts a lead owned by a Queue , then change ownership Contact, Account, Opportunity to Sales Rep user who is converting.
3) Sales Manager and Executive can convert their teams' leads. If a Sales Manager or Executive converts a sales user's Lead, ownership of lead, opportunity, account and contact should remain sales rep
i'm using this code
Database.LeadConvert lc =newdatabase.LeadConvert();
lc.setLeadId(lead.Id);
LeadStatus convertstatus = [select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvert[] lcArray =newDatabase.LeadConvert[] {lc};
Database.LeadConvertResult[] results = Database.convertLead(lcArray);
System.assert(results[0].IsSuccess());
queue can have public groups and that public group can have role and subordinate.and that role and subordinate can have many users.
can someone provide me the query to get users from a queue based on this structure.All help is highly appreciated
Please refer to below code
public static Set<Id> recursiveGetUserIds(set<Id> userOrGroupIds){
set<Id> userIds = new set<Id>();
set<Id> groupIds = new set<Id>();
List<GroupMember> groupMemberList = [Select UserOrGroupId From GroupMember where GroupId IN:userOrGroupIds];
for(GroupMember gm : groupMemberList){
string userOrGroupId = gm.UserOrGroupId;
string init = userOrGroupId.substring(0,3);
if(init == '005'){
userIds.add(gm.UserOrGroupId);
}else{
groupIds.add(gm.UserOrGroupId);
}
}
if(groupIds.size()>0){
Set<id> groupId = new set<id>();
Set<id> roleId = new set<id>();
Set<id> roleAndSubId = new set<Id>();
for(Group gp : [Select Id, Type, relatedId From Group Where Id =:groupIds]){
if(gp.Type == 'Role'){
roleId.add(gp.relatedId);
}
else if(gp.Type== 'RoleAndSubordinates'){
roleAndSubId.add(gp.relatedId);
}
else if(gp.Type== 'PRMOrganization'){
roleId.add(gp.relatedId);
}
else if(gp.Type== 'Regular'){
groupId.add(gp.id);
}
}
if(roleAndSubId.size()>0){
roleId.addAll(getAllSubRoleIds(roleAndSubId));
}
if(roleId.size()>0){
List<user> userList= [select id from user where UserRoleId IN:roleId];
for(User u: userList){
userIds.add(u.id);
}
}
if(groupId.size()>0){
userIds.addAll(recursiveGetUserIds(groupId));
}
}
return userIds;
}
public static Set<ID> getAllSubRoleIds(Set<ID> roleIds) {
Set<ID> currentRoleIds = new Set<ID>();
for(UserRole userRole :[select Id from UserRole where ParentRoleId IN :roleIds]){
currentRoleIds.add(userRole.Id);
}
if(currentRoleIds.size() > 0){
currentRoleIds.addAll(getAllSubRoleIds(currentRoleIds));
}
return currentRoleIds;
}