You need to sign in to do that
Don't have an account?
SharathChandra
Trigger
trigger SendEmailAfterCaseCreated on Case (after insert) {
for(Case c:trigger.new)
{
System.debug(trigger.size);
System.debug(c.Contact.Email);
System.debug(c.Status);
}
}
I'm creating a case for contact which is having email address but i'm not able get email address when i debug
can anyone give the reason
Please help me
Its giving me null value
in triggers you can't get the referenced values you need to query to get the same
Thanks its working.
Can you provide me reference where it is given?
Like kiran_mutturu said above, you won't have any of the related values from your trigger. Look at it this way; it's a trigger on the Case object and you want to pull in information about the related Contact. When the trigger is running, it would have to pull in all of the related records' data as it doesn't know what you're going to need to access.. Out of the box that would be all the Contact and Account fields, leaving a lot of overhead after every insert.
What I'd do is create a separate class that contains all of the code for when a Case meets your criteria, pass a set of IDs for any triggered Contacts (covered for single or bulk), then handle the query in a method within that class and do the rest of your work there.
Trigger:
Class:
SendEmailAfterCaseCreated.cls