You need to sign in to do that
Don't have an account?
Adding Records to an object
I want to create a class that will allow me, on a monthy basis, to take a list of records from one object and add it to another.
Scenerio: I have an object Service_Center__c that has the names of all my service centers. On a monthly basis I want to query all the Services_center__C.name and place that list of Service Centers into another custom object Quota__c. I want it to map the following:
Services_center__C.name - Quota__c.Servicer_center_name__c
01/01/2014 - Quota__c.Period_Start_date__c (this is a date field)
0 - Quota__c.quota__c (this is an integer)
How do I go about doing this?
Your batch job will query for the Service_Center__c for the scope, and then create your Quota records in the execute method like below:
Your schedulable class will kick off the batch job:
Then if you go into Setup->Develop->Apex Classes, you can kick off the "MyServiceCenterSchedulable" class on a schedule using the "Scheduled Apex" button at the top of the Apex Classes list.
See the following links for more info on Batches and Schedulable Apex:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm
Thanks for the help. I am getting an error on line three of the MyServiceCenterBatch class:
Any ideas?
Thanks,
Todd B.