You need to sign in to do that
Don't have an account?
Shubham Sinha 56
How to send email alert using batch class
Hello Everyone,
I have a requirement where I need to send an email alert to the owner of the lead if a Lead has been in 'New' Status for 48 hours i.e. after 48 hours owner should get an email if the status remains 'New' for 48 hours and also if the same lead has been in "Working" status for 5 days ,after 5 days also i need to send an email alert to the owner of the lead.
Can i perform both the action from a single batch. If yes then how can I query for both the condition.Please help me on this.
I have a requirement where I need to send an email alert to the owner of the lead if a Lead has been in 'New' Status for 48 hours i.e. after 48 hours owner should get an email if the status remains 'New' for 48 hours and also if the same lead has been in "Working" status for 5 days ,after 5 days also i need to send an email alert to the owner of the lead.
Can i perform both the action from a single batch. If yes then how can I query for both the condition.Please help me on this.
>> https://developer.salesforce.com/forums/?id=9062I000000IGMgQAO#:~:text=%2F%2FSend%20an%20email%20to,SingleEmailMessage()%3B
The above link has an implementation of sending an email with a batch class, you can try checking this once:
For the query you can try checking this Soql and modifying to fit the API names in your org:
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Greetings!
1. First of all, you have to create a custom field in Lead.
Data Type - Date
Field Label - statusChangeDate
Field Name - statusChangeDate
Default Value - TODAY()
2. Create a Process builder,
Process Name - Lead Status Change
API Name - Lead_Status_Change
The process starts when - A record changes
Click on save.
3. Creating Process builder
a. Add Object
-> Object - Lead
-> Start the process - when a record is created or edited
-> Save
b.Add Criteria
-> Criteria Name - IsStatusChanged
-> Criteria for Executing Actions - Conditions are met
-> Set Conditions
Field - Status
Operator - Is changed
Type - Boolean
Value - True
Conditions - All of the conditions are met (AND)
Save
-> MMEDIATE ACTIONS -> Add Action
Action Type - Update Records
Action Name - updateStatusChangeDate
Record Type - Select the Lead record that started your process
Criteria for Updating Records - No criteria—just update the records!
-> Set new field values for the records you update
Field - statusChangeDate
Type - Formula
Value - TODAY()
Save
4. Activate the process builder by click on Activate.
5. Create a Apex Batchable and Schedulable class that runs daily sends mail to the owner.
6. Schedule this batch using Cron expression.
example for a daily morning at 8. If this helped you please mark it as the best answer.
Thank you!
Regards
Suraj Tripathi.