Skip to main content
Rollback to Revision 2
Source Link
Aman Patil
  • 480
  • 4
  • 15

Seems Like You have groupMemberRecList query inside a loop and that is not a good practise in SF, Take the query out of the loop

refer as below

List<Id> usersRecordToUpdateId = new List<Id>();

Map<Id,List<String>> esfgroup = new Map<Id,List<String>>();

List<String> newgrouplist = new List<String>();

List<String> groupNamesList=new List<String>{'ESF FSGUsers','ESF_TGS_POA','NLO Users','ESF_Single Desk','ESF_TGS_Delivery'};

for(User u : usrList){
    usersRecordToUpdateId.add(u.id);
}

if(!usersRecordToUpdateId.isEmpty()){
   
    List<GroupMember> groupMemberRecList=[select id,GroupId,Group.Name,UserOrGroupId, Group.developerName from GroupMember where UserOrGroupId in :usersRecordToUpdateId AND Group.name in :groupNamesList WITH SECURITY_ENFORCED LIMIT 1];
    system.debug('check line 98: ' +groupMemberRecList);
}

Seems Like You have groupMemberRecList query inside a loop and that is not a good practise in SF, Take the query out of the loop

refer as below

List<Id> usersRecordToUpdateId = new List<Id>();

Map<Id,List<String>> esfgroup = new Map<Id,List<String>>();

List<String> newgrouplist = new List<String>();

List<String> groupNamesList=new List<String>{'ESF FSGUsers','ESF_TGS_POA','NLO Users','ESF_Single Desk','ESF_TGS_Delivery'};

for(User u : usrList){
    usersRecordToUpdateId.add(u.id);
}

if(!usersRecordToUpdateId.isEmpty()){
   
    List<GroupMember> groupMemberRecList=[select id,GroupId,Group.Name,UserOrGroupId, Group.developerName from GroupMember where UserOrGroupId in :usersRecordToUpdateId AND Group.name in :groupNamesList WITH SECURITY_ENFORCED LIMIT 1];
    system.debug('check line 98: ' +groupMemberRecList);
}

Seems Like You have groupMemberRecList query inside a loop and that is not a good practise in SF, Take the query out of the loop

refer as below

List<Id> usersRecordToUpdateId = new List<Id>();

Map<Id,List<String>> esfgroup = new Map<Id,List<String>>();

List<String> newgrouplist = new List<String>();

for(User u : usrList){
    usersRecordToUpdateId.add(u.id);
}

if(!usersRecordToUpdateId.isEmpty()){
   
    List<GroupMember> groupMemberRecList=[select id,GroupId,Group.Name,UserOrGroupId, Group.developerName from GroupMember where UserOrGroupId in :usersRecordToUpdateId WITH SECURITY_ENFORCED LIMIT 1];
}

Rollback to Revision 1
Source Link
Aman Patil
  • 480
  • 4
  • 15

Seems Like You have groupMemberRecList query inside a loop and that is not a good practise in SF, Take the query out of the loop

refer as below

List<Id> usersRecordToUpdateId = new List<Id>();

Map<Id,List<String>> esfgroup = new Map<Id,List<String>>();

List<String> newgrouplist = new List<String>();

List<String> groupNamesList=new List<String>{'ESF FSGUsers','ESF_TGS_POA','NLO Users','ESF_Single Desk','ESF_TGS_Delivery'};

for(User u : usrList){
    usersRecordToUpdateId.add(u.id);
}

if(!usersRecordToUpdateId.isEmpty()){
   
    List<GroupMember> groupMemberRecList=[select id,GroupId,Group.Name,UserOrGroupId, Group.developerName from GroupMember where UserOrGroupId in :usersRecordToUpdateId AND Group.name in :groupNamesList WITH SECURITY_ENFORCED LIMIT 1];
    system.debug('check line 98: ' +groupMemberRecList);
}

Seems Like You have groupMemberRecList query inside a loop and that is not a good practise in SF, Take the query out of the loop

refer as below

List<Id> usersRecordToUpdateId = new List<Id>();

Map<Id,List<String>> esfgroup = new Map<Id,List<String>>();

List<String> newgrouplist = new List<String>();

for(User u : usrList){
    usersRecordToUpdateId.add(u.id);
}

if(!usersRecordToUpdateId.isEmpty()){
   
    List<GroupMember> groupMemberRecList=[select id,GroupId,Group.Name,UserOrGroupId, Group.developerName from GroupMember where UserOrGroupId in :usersRecordToUpdateId WITH SECURITY_ENFORCED LIMIT 1];
}

Seems Like You have groupMemberRecList query inside a loop and that is not a good practise in SF, Take the query out of the loop

refer as below

List<Id> usersRecordToUpdateId = new List<Id>();

Map<Id,List<String>> esfgroup = new Map<Id,List<String>>();

List<String> newgrouplist = new List<String>();

List<String> groupNamesList=new List<String>{'ESF FSGUsers','ESF_TGS_POA','NLO Users','ESF_Single Desk','ESF_TGS_Delivery'};

for(User u : usrList){
    usersRecordToUpdateId.add(u.id);
}

if(!usersRecordToUpdateId.isEmpty()){
   
    List<GroupMember> groupMemberRecList=[select id,GroupId,Group.Name,UserOrGroupId, Group.developerName from GroupMember where UserOrGroupId in :usersRecordToUpdateId AND Group.name in :groupNamesList WITH SECURITY_ENFORCED LIMIT 1];
    system.debug('check line 98: ' +groupMemberRecList);
}

Seems Like You have groupMemberRecList query inside a loop and that is not a good practise in SF, Take the query out of the loop

refer as below

List<Id> usersRecordToUpdateId = new List<Id>();

Map<Id,List<String>> esfgroup = new Map<Id,List<String>>();

List<String> newgrouplist = new List<String>();

List<String> groupNamesList=new List<String>{'ESF FSGUsers','ESF_TGS_POA','NLO Users','ESF_Single Desk','ESF_TGS_Delivery'};

for(User u : usrList){
    usersRecordToUpdateId.add(u.id);
}

if(!usersRecordToUpdateId.isEmpty()){
   
    List<GroupMember> groupMemberRecList=[select id,GroupId,Group.Name,UserOrGroupId, Group.developerName from GroupMember where UserOrGroupId in :usersRecordToUpdateId AND Group.name in :groupNamesList WITH SECURITY_ENFORCED LIMIT 1];
    system.debug('check line 98: ' +groupMemberRecList);
}

Seems Like You have groupMemberRecList query inside a loop and that is not a good practise in SF, Take the query out of the loop

refer as below

List<Id> usersRecordToUpdateId = new List<Id>();

Map<Id,List<String>> esfgroup = new Map<Id,List<String>>();

List<String> newgrouplist = new List<String>();

List<String> groupNamesList=new List<String>{'ESF FSGUsers','ESF_TGS_POA','NLO Users','ESF_Single Desk','ESF_TGS_Delivery'};

for(User u : usrList){
    usersRecordToUpdateId.add(u.id);
}

if(!usersRecordToUpdateId.isEmpty()){
   
    List<GroupMember> groupMemberRecList=[select id,GroupId,Group.Name,UserOrGroupId, Group.developerName from GroupMember where UserOrGroupId in :usersRecordToUpdateId AND Group.name in :groupNamesList WITH SECURITY_ENFORCED LIMIT 1];
    system.debug('check line 98: ' +groupMemberRecList);
}

Seems Like You have groupMemberRecList query inside a loop and that is not a good practise in SF, Take the query out of the loop

refer as below

List<Id> usersRecordToUpdateId = new List<Id>();

Map<Id,List<String>> esfgroup = new Map<Id,List<String>>();

List<String> newgrouplist = new List<String>();

for(User u : usrList){
    usersRecordToUpdateId.add(u.id);
}

if(!usersRecordToUpdateId.isEmpty()){
   
    List<GroupMember> groupMemberRecList=[select id,GroupId,Group.Name,UserOrGroupId, Group.developerName from GroupMember where UserOrGroupId in :usersRecordToUpdateId WITH SECURITY_ENFORCED LIMIT 1];
}

Source Link
Aman Patil
  • 480
  • 4
  • 15
Loading