+ Start a Discussion
Michael PuglieseMichael Pugliese 

Updating Apex

Hi, 

I recently made a minor change to an older Apex Class - essentially I updated a query to exclude certain picklist values (added set and excluded in query):
Set<String> ExcludedVerticals = new Set<String>{'Vertical1', 'Vertical2'};//sets verticals to be excluded from NPS surveys
        Set<ID> accountIdsToSendEmailTo = new Set<ID>();
        for(Contract ctrct: [Select ID, AccountID, Subscription_Start_Date__c
                             from Contract 
                             where AccountID in: accountIDs
                             and Contract_Status__c =: 'Active'
                             and Subscription_Start_Date__c !=: null
                             and Account.Vertical__c not in: ExcludedVerticals])
This class sends out NPS survey based on contract information. In order for me to save this on Sandbox I had to delete the existing scheduled job. 

My questions is how do I recreate the scheduled job to execute the class? I know it's not as important on Sandbox, but I'd like to know the exact process in preperation for moving to production. 

I'll also add that I'm not very experienced in development, but slowly making by way through small projects like this so any and all help would be appreciated!

We do have existing Test and Schedule classes that reference the class I edited. 

Thanks, 
Michael 
Best Answer chosen by Michael Pugliese
Josh DuerJosh Duer
In Setup>Develop>Apex Classes there is a button called Schedule Apex.  If you click on this button you can create a new scheduled job, selecting the apex class, and defining how often and what time it should run.  I would advise you go to Monitor->Jobs->Sceduled Jobs and locate the existing job. There should be a Manage Action on the Scheduled Apex jobs that will show you the current setup for the scheduled job so you will know how it is currently configured so the job can be configured the same way it is currently if not updating or changing when it runs.