You need to sign in to do that
Don't have an account?
Wik
Error in trigger
Hi,
trigger send_notification on Quote (after update) {
Quote inquery = trigger.new[0];
Quote.email__c = 'Gaurav.Raj@fs.utc.com';
String[] toAddresses = new String[] {inquery.email__c};
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
//mail.setTargetObjectId(inquery.OwnerID);
mail.setSenderDisplayName('Salesforce Support');
mail.setUseSignature(false);
mail.setBccSender(false);
mail.setSaveAsActivity(false);
if (Trigger.isUpdate) {
if(inquery.XYZ__c == 'True') {
EmailTemplate et=[Select id from EmailTemplate where ID=:'00X6000000126rL'];
mail.setTemplateId(et.id);
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
it throws an error :
Error: Compile Error: Expression cannot be assigned at line -1 column -1
trigger send_notification on Quote (after update) {
Quote inquery = trigger.new[0];
Quote.email__c = 'Gaurav.Raj@fs.utc.com';
String[] toAddresses = new String[] {inquery.email__c};
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
//mail.setTargetObjectId(inquery.OwnerID);
mail.setSenderDisplayName('Salesforce Support');
mail.setUseSignature(false);
mail.setBccSender(false);
mail.setSaveAsActivity(false);
if (Trigger.isUpdate) {
if(inquery.XYZ__c == 'True') {
EmailTemplate et=[Select id from EmailTemplate where ID=:'00X6000000126rL'];
mail.setTemplateId(et.id);
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
it throws an error :
Error: Compile Error: Expression cannot be assigned at line -1 column -1
EmailTemplate et=[Select id from EmailTemplate where ID=:'00X6000000126rL'];
try this updated code.
also you have to bulkify your code and use custom setting instead of hardcoding the id in the above SOQL. Please refer the best practices link below on how to achive this
https://developer.salesforce.com/page/Apex_Code_Best_Practices
here is the bulikified version
EmailTemplate et=[Select id from EmailTemplate where ID='00X6000000126rL'];