function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Guru 91Guru 91 

How to create delivery order 1st of each month?

Hi,
I want to create delivery record on 1st of each month.
How we can do that?


Thanks
Guru
AshishkAshishk
Create a schedule job, which runs on first of every month.

In that you can write the logic of creation of delivery record.
 
global class SomeClass implements Schedulable {
    global void execute(SchedulableContext ctx) {
       insert delivery;
    }
}
Use above class, and schedule it from schedule apex button on apex classes.
 
NagendraNagendra (Salesforce Developers) 
Hi Guru,

This would be something that would be a better fit for
scheduled apex - this will allow you to execute some code according to a date/time schedule. You can schedule the job from the UI or from code, via the developer console.
Take a look at the docs at:
  • http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm
There's a blog post at:
  • http://blog.deadlypenguin.com/blog/2012/05/26/scheduled-actions-in-salesforce-with-apex/
that includes an example of executing code on the first of every month.

You should create a scheduled job. See 
  • http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm.
The code would look something like this (untested):
global class CreateCustObjRecord implements Schedulable{ global void execute (SchedulableContext SC) { Object custObj = new Object(); Object.Name = 'New Custom Object'; Object.CreationDate = current; insert custObj; } }
You then schedule it by clicking "Schedule Apex" in the Setup->Develop->Apex Classes

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra

 
karthikeyan perumalkarthikeyan perumal
 Hello, 

 Write batch apex class to insert  Delivery record  in this class check the condition is date is 1st of every month.

schdule this bacth apex every day basic. 

make sure the class will insert record if the date is 1st of every month. 

Thanks
karthik
 

 
Guru 91Guru 91
Thank you,
It will help my requirement
Can't we do with time dependent workflows.


Thanks
Guru