You need to sign in to do that
Don't have an account?
vfexp31.3955631467313875E12
sends email-template to customer
HI,
I want to sends email-template to contact, based upon Quote-item Field, Actually in Quote-item i have a field Update_del, when the field is true at that time i want to sends email template,
Here quote-Item is child to Quote, having master-details relation ship, in Quote i have a field called Email__c i want to sends email-template to the address which mention in the Email__c field based upon Quote_item Object
I tried Below But i am getting Error at Soql Query
trigger emailtemplate2 on Quote_Item__c(after update)
{
List<Quote_Item__c> oList = Trigger.new;
List<Quote_Item__c> nList = trigger.old;
if(oList[0].Updated_del__c !=nList[0].Updated_del__c) {
Set<Id> QuoteItemIds= new Set<Id>();
List<Quote__c> sList = [select id,Email__c from Quote__c where Quote__r.Email__c =:nList[0].Quote__c.Id limit 1];
// Error Occuring Point
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
if(oList[0].Quote_Item__c== 'true') {
EmailTemplate et=[Select id from EmailTemplate where name = 'quote3' limit 1];
mail.setTemplateId(et.id);
mail.setToAddresses(new String[] {sList[0].email});
mail.setTargetObjectId(sList[0].id);
mail.setSaveAsActivity(false);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
I want to sends email-template to contact, based upon Quote-item Field, Actually in Quote-item i have a field Update_del, when the field is true at that time i want to sends email template,
Here quote-Item is child to Quote, having master-details relation ship, in Quote i have a field called Email__c i want to sends email-template to the address which mention in the Email__c field based upon Quote_item Object
I tried Below But i am getting Error at Soql Query
trigger emailtemplate2 on Quote_Item__c(after update)
{
List<Quote_Item__c> oList = Trigger.new;
List<Quote_Item__c> nList = trigger.old;
if(oList[0].Updated_del__c !=nList[0].Updated_del__c) {
Set<Id> QuoteItemIds= new Set<Id>();
List<Quote__c> sList = [select id,Email__c from Quote__c where Quote__r.Email__c =:nList[0].Quote__c.Id limit 1];
// Error Occuring Point
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
if(oList[0].Quote_Item__c== 'true') {
EmailTemplate et=[Select id from EmailTemplate where name = 'quote3' limit 1];
mail.setTemplateId(et.id);
mail.setToAddresses(new String[] {sList[0].email});
mail.setTargetObjectId(sList[0].id);
mail.setSaveAsActivity(false);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
Please modify- where Quote__c = :nList[0].Quote__c. Also change mail.setToAddresses(new String[] {sList[0].email}); instead of email, use email__c
Thanks
Vikash_SFDC