You need to sign in to do that
Don't have an account?
Vivek Dangate
In the batch apex, I want to send email if the 'count of record created today' is greater than 'the count of record created t yesterday'
In the batch apex, I want to send email if the 'count of record created today' is greater than 'the count of record created t yesterday'. Any help is really appreciated.
The below code is in context of account object. You can customize it for your custom object and get started
Make sure you are replacing with your email Id in the code
Run this code by using below snippet in dev console
If this information helps, please mark the answer as best. Thank you
All Answers
The below code is in context of account object. You can customize it for your custom object and get started
Make sure you are replacing with your email Id in the code
Run this code by using below snippet in dev console
If this information helps, please mark the answer as best. Thank you
I want to send a link for the list view of the object in the email. Is that possible. thank you in advance
As the follow-up question is different from the original question posted, can you please post it as a new question for better tracking of efforts?
Also, please consider marking the provided answer as best to close the thread so it can help others too in the future.
Appreciate your understanding!
Thank you
1. Create a custom object to store the record counts for each day.
2. Create a batch class that retrieves the record count for the given object and compares it with the previous day's count.
3. Schedule the batch class to run daily.
Here's an example of the code:
Custom Object:
1. Create a custom object Daily_Record_Count__c with the following fields:
- Date__c (Date, unique): The date when the record count was taken.
- Record_Count__c (Number): The number of records created on the given date.
Batch Class:
Create a batch class that implements the Database.Batchable<sObject> and Database.Stateful interfaces.
Replace YourCustomObject__c with the API name of the object you want to monitor.
Schedule the Batch Class: Schedule the batch class to run daily using the System.schedule method or through the Salesforce UI.
If you find this useful, kindly consider selecting it as the Best Answer.
Thank you.
Divya Agrawal