You need to sign in to do that
Don't have an account?
Apex Schedular
Hi,
I'm having Date field in my contact object.I want to update that field at the end of the every month.For that i want to write apex schedular.To update that field.Here is the class and i want use schedular to this class.
public class Dat{
public Date t=System.Today();
//public contact con{get;set;}
Public List<contact> conn{get;set;}
Public string day;
public Dat(){
Datetime myDate = datetime.newInstance(t.year(), t.month(), t.day());
day = myDate.format('MMM-yyyy');
con();
}
public void con(){
for(contact con:[select Date__c from contact])
{
con.Date__c=day;
conn.add(con);
}
Update conn;
}
}
hi,
Use System.Schedule method
Refer this
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#CSHID=apex_triggers.htm|StartTopic=Content%2Fapex_triggers.htm|SkinName=webhelp
http://infallibletechie.blogspot.in/2012/09/birthday-reminder-or-automatic-birthday.html
http://infallibletechie.blogspot.in/2012/05/apex-scheduler.html
Check these links for more info...
Regards,
Magulan D
Salesforce.com certified Force.com Developer.
SFDC Blog
SFDC Site
If this post is your solution, kindly mark this as the solution.
Use System.Schedule method
SampleSchedule ss = new sampleschedule();
Hi,
If i use the System.Schedule.I can able to select a particular day in every month.So that my schedular will work on that day.For example:-If i'm taking 30th of every month.The schedular will fire 30th of every month.
But my condtion is the schedular has to fire end of every month.i.e......If you take januray...The schedular has to fire on 31st of January....If take Febuary..It has to fire 28th...So it has to continue like...
360venky,
Yes. If you implement your class using Schedulable interface, you can schedule it to run on the last day of each month.
This is a built-in option of the scheduler.
-Hengky-