+ Start a Discussion
sachin joshisachin joshi 

Apex Schedular Class

I want to schedule my class to create child records 30 days after the created date of parent records, as I am beginner to Apex I have no idea to do that should I use conditions in my apex claas or somrthing else? Please suggest me how can I do that, It would be a great help. 
Bertrand PolusBertrand Polus

Not sure if it is the easiest solution but here is a solution that should work:
   - Create a field 'CreateChild__c' of type picklist on the parent table (possible values: 'Pending', 'Creation', 'Created')
   - Create a workflow rule on your parent table when CreateChild__c = 'Pending'
   - Add a Time-Dependent Workflow action to the previously created workflow rule to be executed 30 days after the CreatedDate
   - Add a FieldUpdate action to this Time-Dependent WF action, which updates the CreateChild__c field to 'Creation'
   - Add a trigger on the parent table which, when the field CreateChild__c is updated to 'Creation' creates the child records and updates the status to 'Created'.

Another solution:
   - Creates a Batch job executed every day
   - This batch job takes the list of the parents rows having been created 30 days ago and creates the child rows corresponding
Hoping this will solve your problem...