function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robert StathisRobert Stathis 

Trying to compare a list to another list

I need to compare one list to another but it is not allowing me to do so
public class ContactTriggerHandler {
    public static void IsPricingLetter(List<Contact> con){
            Id CRMUSRecordType = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('CRM Contact US').getRecordTypeId();
           //Get a list of all contact ID's that have an active Relationship and of the Pricing Letters type 
        list<accountcontactrelation> PricingLettersCheck = new list<accountcontactrelation>([SELECT id,ContactID,roles From accountContactRelation 
                                                                                           WHERE contactid in :con AND Roles INCLUDES (:label.messer_us_pricing_letter) AND isactive=true]);
        
        
        List<Contact> ContactLookup = new List<Contact>();
        for(Contact ConList :con){
            if (ConList.recordtypeid==CRMUSRecordType){
    //I NEED TO COMPARE THE PRICINGLETTERS CHECK HERE>>       if(conlist.id IN :PricingLettersCheck.contactid){
                
                ContactLookup.add(ConList);
                }
                    }//end if
        }//end for loop

 
Shri RajShri Raj
public class ContactTriggerHandler {
    public static void IsPricingLetter(List<Contact> con){
        Id CRMUSRecordType = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('CRM Contact US').getRecordTypeId();
        //Get a list of all contact ID's that have an active Relationship and of the Pricing Letters type 
        list<accountcontactrelation> PricingLettersCheck = new list<accountcontactrelation>([SELECT id,ContactID,roles From accountContactRelation 
                                                                                           WHERE contactid in :con AND Roles INCLUDES (:label.messer_us_pricing_letter) AND isactive=true]);
        
        
        List<Contact> ContactLookup = new List<Contact>();
        for(Contact ConList :con){
            if (ConList.recordtypeid==CRMUSRecordType){
                for (accountcontactrelation pricingLetter : PricingLettersCheck) {
                    if (pricingLetter.contactid == ConList.id) {
                        ContactLookup.add(ConList);
                        break;
                    }
                }
            }
        }
    }
}