I have some code like this. While the conditionals I have are working fine what I cannot check for is if Contact lCon is NOT contained in the sfdcList. I have been trying to find a way to set up a Set or List and contains() method to do this but it all doesn't seem to work as I expect.
lookerByIds is a Map<Id, List<Contact>>
So the intent here is that each element of the sfdcList for a given Id is checked against a list of contacts by Id. See if they have conditionals like so and if the lCon list is in the sfdcList at all. Then do something else.
for(Contact con : sfdcList){
//specifies the same key value pair as the queried Contact
for(Contact lCon : lookerByIds.get(con.AccountId)) {
if(con.Email !=Null && lCon.Email !=Null) {
//compares email values
if(!con.Email.equalsIgnoreCase(lCon.Email)) {
continue;
}
if(con.Email.equalsIgnoreCase(lCon.Email)) {
//adjusts record
if(con.status__c == Null)
{
con.status__c = 'Billing Contact';
syncList.add(con);
//system.debug(con);
}
if(con.status__c != Null && !con.status__c.contains('Billing Contact')) {
con.status__c = con.status__c + ';Billing Contact';
syncList.add(con);
//system.debug(con);
}
if(con.LastName.equals('Accounts Payable') && con.status__c.contains('Billing Contact')) {
continue;
}
//system.debug(con);
}
else {
Contact bub = new Contact(LastName = 'Accounts Payable', AccountId = lCon.AccountId, status__c = 'Billing Contact', Email = lCon.Email);
syncList.add(bub);
}
if(con.Id != lCon.Id)