I've a simple conceptual doubt - Would really appreciate if someone would explain me the reason for this behaviour:
I'm inserting a new contact from console and following is the snippet:
Contact c = new Contact();
c.Email = 'TSTCONTACTJAN11TEST123@TEST.COM';
c.LastName = 'TEST';
c.CurrencyIsoCode = 'USD';
insert c;
system.debug('+++'+c.Email);
I've written a simple before insert trigger which would check if the Email is not null then would make the Email lower case and add '.com' to it.
For(Contact c: newCon){
if(c.Email != null){
c.Email = c.Email.toLowerCase() + '.com';
}
}
So when I'm running the first snippet in developer console the debug result is TSTCONTACTJAN11TEST123@TEST.COM
Shouldn't it be tstcontactjan11test123@test.com.com
since before trigger will be acting upon it?
I'm getting tstcontactjan11test123@test.com.com
only when I run the following snippet along with the first snippet:
Contact newCon = [SELECT Id, Email FROM Contact Where Id = :c.Id LIMIT 1];
System.debug('+++ After Insert Email Value: '+newCon.Email);