+ Start a Discussion
TestingUserTestingUser 

How to store collection Variable values to use in another loop

I have a requirement to get a list of Users from a particular Group, check for their Permission Set and send custom notification to these Users. Is this achievable through Lightning Flow. I am not able to store the list into a variable as we do in Apex. Any help is appreciated. 
OFröhlichOFröhlich
Hi,

you are able to store the selected values in a collection variable in a flow too. When you create a new variable, you can set the flag - 
Allow multiple values (collection). Later on you can use it for. e.g. in a loop.

If this helps, please mark as Best Answer to help others too.
TestingUserTestingUser
Thanks but I have tried doing that. So basically I have to convert below code into my Flow
for(Case c: [SELECT Id, CreatedById FROM Case WHERE Id =: caseId]){
userId = c.CreatedById;
}        
Id permSetId = [SELECT Id FROM PermissionSet WHERE Name ='XXXXX'].Id;
for(GroupMember grpMem : [SELECT Id, UserOrGroupId FROM GroupMember WHERE UserOrGroupId =: userId]){
  lGrpid.add(grpMem.groupId);    
}
for(GroupMember grpMem : [SELECT Id, UserOrGroupId FROM GroupMember WHERE GroupId =: lGrpid]){
  luserList.add(grpMem.UserOrGroupId);    
}
for(PermissionSetAssignment p: [SELECT AssigneeId,Id,PermissionSetGroupId,PermissionSetId 
                                FROM PermissionSetAssignment
                            WHERE PermissionSetId =: permSetId
                            AND AssigneeId =: luserIds]){
luserIds.add(p.AssigneeId);
}

I have to get a list of Users within that particular Group , with that Permission Set .