function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HTANIRSHTANIRS 

Apex schedule job to check newly inserted opportunity

Hi,
i need help in creating Apex schedule jobs to check every 5 mins whether opportunity is newly created or not. I don't know how to start.
Please need your help to complete.

Thanks
Best Answer chosen by HTANIRS
GovindarajGovindaraj
Hi,
global class newOptys implements Schedulable {
    global void execute(SchedulableContext ctx) {
        List<Opportunity> newOpty = new List<Opportunity>();
        List<Opportunity> lstOpty = [SELECT Id, Name FROM Opportunity WHERE CreatedDate < TODAY];
        for(Opportunity optyObj : lstOpty) {
               newOpty.add(optyObj .Name);
               /* More logic */
        }
    }   
}
Refer below link to schedule this for every 5 mins.
https://howtodoitinsalesforce.blogspot.com/2016/12/run-schedule-class-in-every-5-mins-in.html

Thanks,
Govindaraj.S

All Answers

GovindarajGovindaraj
Hi,
global class newOptys implements Schedulable {
    global void execute(SchedulableContext ctx) {
        List<Opportunity> newOpty = new List<Opportunity>();
        List<Opportunity> lstOpty = [SELECT Id, Name FROM Opportunity WHERE CreatedDate < TODAY];
        for(Opportunity optyObj : lstOpty) {
               newOpty.add(optyObj .Name);
               /* More logic */
        }
    }   
}
Refer below link to schedule this for every 5 mins.
https://howtodoitinsalesforce.blogspot.com/2016/12/run-schedule-class-in-every-5-mins-in.html

Thanks,
Govindaraj.S
This was selected as the best answer
HTANIRSHTANIRS
Hi Govindaraj,

Thanks for your help. It helped me to create scheduled jobs. If Possible please check my code it is not inserting a record. Let me know your comments. I raised my clarification in below URL.

https://developer.salesforce.com/forums/ForumsMain?id=9062I000000QukxQAC

 
GovindarajGovindaraj
Sure !