I'm receiving the following error:
Illegal assignment from
List<OpportunityContactRole>
toList<String>
When I try to query from OpportunityContactRole
and store it into a new list. I'm pretty new to apex, so I'm kind of confused where I'm going wrong. Here's my code:
public class testOCR {
public static void testOCRmethod(){
// Create a list that stores the query data
List<string> ContactList = [SELECT OpportunityId,Contact.Referral_ID__c FROM OpportunityContactRole WHERE ContactId IN (SELECT Id FROM Contact WHERE Referral_ID__c != null) AND OpportunityId IN (SELECT Id FROM Opportunity WHERE Referral_ID__c = null) AND CreatedDate <= TODAY];
Integer ListSize = ContactList.size();
if( ListSize < 1 ) {
system.debug('List is too small');
} else {
// list is a proper size
system.debug('List is big enough');
for(string x : ContactList) {
system.debug(x);
}
}
}
}
Originally I had it set as List<OpportunityContactRole>
which worked, sort of. The problem was that when I would check my debug log, it wasn't saving the Referral_ID__c
value, which is why I was trying to change it to a string instead.
Any ideas where I'm going wrong?