You need to sign in to do that
Don't have an account?
Lead Deletion Notification
Need help on creating an apex trigger. This trigger will need to notify me via email when a Lead with a certain picklist value is deleted from Salesforce from our users. Here are the core details:
Lead Record Type: Lead MF
Picklist API: Lead Source
Picklist Value: BODY Meters
so, if the Lead Record Type is Lead MF and the Picklist Lead Source with the picklist value BODY Meters is selected and a user deletes this lead, I want the ability to receive an email of the Lead being deleted.
thanks!
Lead Record Type: Lead MF
Picklist API: Lead Source
Picklist Value: BODY Meters
so, if the Lead Record Type is Lead MF and the Picklist Lead Source with the picklist value BODY Meters is selected and a user deletes this lead, I want the ability to receive an email of the Lead being deleted.
thanks!
Please use below trigger.Update the trigger condition as per your custom field API Name:
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
Can we shorten this?
I, the Admin, will be the only person receiving the email notifications.
Can you modify the Apex code to be shorter?
Thanks!
// Step 0: Create a master list to hold the emails we'll send
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
for (Lead leadobj : Trigger.old) {
if (leadobj.RecordType == Lead MF && lead.sourcetype == 'BODY Meters') {
// Step 1: Create a new Email
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
// Step 2: Set list of people who should get the email
List<String> sendTo = new List<String>();
sendTo.add('addyouremail@test.com');
mail.setToAddresses(sendTo);
// Step 3. Set email contents - you can use variables!
mail.setSubject('Test Subject');
String body = 'Test Body';
mail.setHtmlBody(body);
// Step 5. Add your email to the master list
mails.add(mail);
}
}
// Step 6: Send all emails in the master list
Messaging.sendEmail(mails);
}
I have been passing the MasterRecordID value in to the email body instead of using it as criteria for now, to see if it is populating, but is alwasys returning an null value.
Please help if you can.
Thank you,
Brian