Skip to content

Instantly share code, notes, and snippets.

@sakthivelsfdc
Last active March 2, 2020 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakthivelsfdc/b0b73a68ba58004686a3b13c8670ba84 to your computer and use it in GitHub Desktop.
Save sakthivelsfdc/b0b73a68ba58004686a3b13c8670ba84 to your computer and use it in GitHub Desktop.
global class contactUpdateFromScheduleClass implements Schedulable {
/*
This is a ScheduleClass to run every hours after 6 mins to update contact records
*/
// Execute below code in developer console
// It schedules this class to run every hour after 6 minutes (like 8:06, 9:06, 10:06, etc..)
// This is one minute after the exchange rates are fetched from Open Exchange Rates.
/*
contactUpdateFromScheduleClass contactUpdate = new contactUpdateFromScheduleClass();
// Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
String schedule = '0 6 * * * ?';
String jobID = System.schedule('Contact Update', schedule, contactUpdate);
*/
global void execute(SchedulableContext sc) {
//Fetch to All Contact Records
List<Contact> listContact = new List<Contact>([SELECT Id, FirstName, LastName, Email
FROM Contact]);
// Loop through list and update Contact Name
for (Contact con : listContact){
con.Description = con.FirstName + ' - ' + con.LastName +' Update from Schedulable Class';
}
update listContact;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment