You need to sign in to do that
Don't have an account?
Glen.ax1034
email.toaddresses.contains
email.toAddresses.contains('teameast@2p0b7hdjfv8olr8hubm9unhg.37creai.7.case.salesforce.com'))
Save Error: Method does not exist or incorrect signature: [List <String>].contains(String)
how do i check to see if the to.Addresses field contains that string/email?
Switch it to a set and use the .contains() method. Or you could iterate through each value of the List like so:
All Answers
Switch it to a set and use the .contains() method. Or you could iterate through each value of the List like so:
that would make sense. then i raise you a question. i started getting an error that caused me to check if the toaddress is null.
so.. now my question is... how do i write a test class so that it isn't null?I'm getting 100% test coverage except for the line above: addresses.addAll(email.toAddresses); because it's pulling a null on the email.toAddresses. That is the perceived problem.
You could do something like
if(System.isRunningTests() && email.toAddresses == null){
email.toAddresses = new List<String>{'foo@foo.com'};
}
before your check, then when you're running tests and email.toAddresses == null, you will populate the toAddresses with an email address to use later.
http://boards.developerforce.com/t5/Apex-Code-Development/How-to-use-isRunningTest-from-winter-11-new-apex-code-features/td-p/208799
Should be: Test.isRunningTest();