Trying to create a Trigger in Apex where if the Contact is related to an Account and has a Pricing Letter role on that relationship. If there is a Pricing Letter relationship, the user should not be able to delete the Mailing Street on the Contact object. The below fires every time I try to change the Mailing Street even if it not blank. Any ideas?
List<Contact> relatedcontacts = new list<Contact>([SELECT id,mailingstreet FROM Contact WHERE id IN(SELECT ContactId
FROM accountcontactrelation
WHERE roles INCLUDES ('Pricing Letters')) AND id IN : Trigger.new]);
for(Contact c : relatedcontacts){
if(c.MailingStreet==null){
Contact con = Trigger.newMap.get(c.id);
con.addError('Mailing Street on Pricing Letter Contacts cannot be null');
}//End If Statement
}//End For Loop
}//End Class```