+ Start a Discussion
kranthi kumar madanamonikranthi kumar madanamoni 

How can i achieve this condition?

when status__c= true && price__C>3000, update status__c=false and send email using email template to u1@gmail.com using trigger
ManojjenaManojjena
Hi kranthi ,
Which object you want to write trigger ? 
SamarSSamarS
Refer this below link, it might be helpful..
https://developer.salesforce.com/forums/?id=906F00000008yhSIAQ
Patcs_1Patcs_1
Hi

In Trigger you can write the condition like below and inside that you can write a code to send an email.

below is the sample code you can try inside your trigger.

if( status__c= true && price__C>3000, update status__c=false)
{
 EmailTemplate  et = [Select e.Id,e.Name,e.subject,e.BrandTemplateId From EmailTemplate e where e.Name='XXXXXXXx' Limit 1];
List<Messaging.SingleEmailMessage> mess = new List<Messaging.SingleEmailMessage>();
list<string> TAdd = new list<string>();
TAdd.add('u1@gmail.com');
Messaging.SingleEmailMessage smail = new Messaging.SingleEmailMessage();       
smail.setTargetObjectId(obj.ownerId);  // Object OwnerID
smail.setTemplateId(et.Id);
smail.setToAddresses(TAdd);
smail.setWhatId(obj.Id); // Object Id
mess.add(smail); 
Messaging.sendEmail(mess);
}

Hope this helps!

Thanks