I'm trying to get records of custom object where MultiSelectPicklist__c have names of publicgroups.
List<String> groupIds = new List<String>();
List<String> groupNames = new List<String>();
for(GroupMember gm :[SELECT Id,GroupId,UserOrGroupId FROM GroupMember WHERE UserOrGroupId = '0051U000006AkQy']){
groupIds.add(gm.GroupId);
}
for(Group g :[SELECT ID,Name FROM Group WHERE Id IN :groupIds]){
groupNames.add(g.Name);
}
for(CustObj__c cust : [Select Id, Name, MultiSelectPicklist__c FROM CustObj__c WHERE MultiSelectPicklist__c INCLUDES (:groupNames)] ){
somelogic
}
Why it says 'Invalid bind expression type of List<'String> for column of type String' in developer console?
Even after converting List to string I'm still not able to get any record
for(GroupMember gm :[SELECT Id,GroupId,UserOrGroupId FROM GroupMember WHERE UserOrGroupId = :userIds[0]]){
groupIds.add(gm.GroupId);
}
for(Group g :[SELECT ID,Name FROM Group WHERE Id IN :groupIds]){
groupNames.add('\'' + g.Name + '\'');
//groupNames.add(g.Name);
}
String listtostring = String.join(groupnames, ',');
List<program__c> newlist = [SELECT Id, Name, MultiSelectPicklist__c FROM Program__c where MultiSelectPicklist__c INCLUDES (:listtostring) ];
system.debug('List of records---'+newlist);
- I tried both
for(Group g :[SELECT ID,Name FROM Group WHERE Id IN :groupIds]){
///groupNames.add('\'' + g.Name + '\'');
groupNames.add(g.Name);
}