I have a requirement . I want to know the number of leads created for every 10 mins and if the leads are not created in last 10mins I want to get an email saying No leads are created in last 10 mins
Can anyone help me how to achieve this
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
You can achieve that by writing a scheduler. Once the scheduler runs then schedule it after 10 min times in apex. If you want to learn how to do it. Then you can follow below forum discussion.
In order to check if there are records which are created in last 10 mins you can use below code snippet.
DateTime pastTime = System.now().addMinutes(-10); List<Lead> leadsCreatedInLast10Minutes = [Select Id from Lead WHERE CreatedDate >= : pastTime]
Now if the leadsCreatedInLast10Minutes.size() is equal to zero then you can send email.