You need to sign in to do that
Don't have an account?
hemant rana
at the end of a month a field value gets updated to 0
hi i have a requirement where at the end of every month a field is set to 0 by itself.
I think about workflow but in worflow i have to create or edit a record then only workflow will fire.
So, please help.
I think about workflow but in worflow i have to create or edit a record then only workflow will fire.
So, please help.
<pre>
global class ScheduledUpdateToZero implements Schedulable {
global void execute(SchedulableContext SC) {
//Update your records here.
}
}
</pre>
Then, to schedule it, you can go into the Developer Console and execute the following anonymous Apex:
<pre>
ScheduledUpdateToZero updater = new ScheduledUpdateToZero();
String sch = '59 59 23 L * ?';
system.schedule('Update field to 0', updater, sch);
</pre>
That should schedule the class to run at 11:59:59 PM on the last day of every month. You can verify that by going to Setup -> Administration Setup -> Monitoring -> Scheduled Jobs. You should see the job "Update field to 0" that you just created on the list.
All Answers
<pre>
global class ScheduledUpdateToZero implements Schedulable {
global void execute(SchedulableContext SC) {
//Update your records here.
}
}
</pre>
Then, to schedule it, you can go into the Developer Console and execute the following anonymous Apex:
<pre>
ScheduledUpdateToZero updater = new ScheduledUpdateToZero();
String sch = '59 59 23 L * ?';
system.schedule('Update field to 0', updater, sch);
</pre>
That should schedule the class to run at 11:59:59 PM on the last day of every month. You can verify that by going to Setup -> Administration Setup -> Monitoring -> Scheduled Jobs. You should see the job "Update field to 0" that you just created on the list.