Skip to content

Instantly share code, notes, and snippets.

@kiran-machhewar
Last active August 29, 2015 14:02
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 kiran-machhewar/51d2daedd8e33aded3bd to your computer and use it in GitHub Desktop.
Save kiran-machhewar/51d2daedd8e33aded3bd to your computer and use it in GitHub Desktop.
public class Notification{
/**
* @description :
* @param jobName Name of the scheduler
* @param durationInMinutes Greater duration than the time interval between scheduler executions.
*/
public static void addNotificationFor(String jobName, Integer durationInMinutes){
Notification__c notification = new Notification__c(
Name = jobName,
External_Code__c = jobName,
Notify__c = false
);
upsert notification External_Code__c;
//This makes sure that it will meet the criteria to send email
notification.Notify__c = true;
notification.Notify_After_One_Hour_Of_This_Time__c = System.Now().addHours(-1).addMinutes(durationInMinutes);
notification.Last_Run__c = System.now();
update notification;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment