0

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

3

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.

https://developer.salesforce.com/forums/?id=906F00000008yFvIAI

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.

2
  • Thanks for the response ! I Created URl in salesforce i.e services/apexrest/LeadData I Created this for every 10mins can I now hard code the url services/apexrest/LeadData/15Minutes or any minutes i want o get the count . Is it possible to Hardcode the url. – Revanth Apr 5 '16 at 20:11
  • I don't understand why you had need to created apex rest service. Here only scheduler would have done the job. – Kiran Machhewar Apr 6 '16 at 6:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.