I have the following List from which I want to pass the UserId field into a set
string filter ='select UserId from OpportunityTeamMember';
List < sObject > filterList = database.query(filter);
System.debug('test: ' + filterList);
Set<Id> filterIds = (new Map<Id,sObject>(filterList)).keySet().clone();
I end up with the OpportunityTeamMember Id's in the Set. If I tried to do this by a loop
Set<Id> filterIds = new Set<Id>();
for(sObject recObj: filterList){
filterIds.add(recObj.UserId);
}
But then I get Variable does not exist: UserId
How do I get the UserId's into the Set
Thanks in advance